lundi 25 septembre 2017

Fastest and most stable way to sort a bunch of classes by 2 of thier members

I have a class:

class foo{
private:
    int group;
    int priority;
public:
    SOMEOTHERSTUFF
}

I am looking for a data structure that can:

  • Store large masses of this class without slowing down too much
  • Is able to insert a new member sorted by group and then by priority (within group)
  • And is quick to interate through all members (by group and by priority)

Something optimal would be something simmilar to a hashtable where

  • the group is the key
  • the overflow is attached to each other like nodes and is automatically sorted

What I mean is:

  • container[1] -> list of all members in group one, sorted by priority
  • container[2] -> same but with members from group 2.

What is the best way to achieve this? I need it to be as safe and as fast as possible so doing this myself isnt good (since I am not that good of a programmer yet)

Aucun commentaire:

Enregistrer un commentaire