My program is based around a set of pairs, namely
typedef std::pair<int,int> innerPair;
typedef std::pair<innerPair,int> setElement;
std::set<setElement> Foo;
The innerPair element is what really defines the setElement, but I need to attach a group ID to every element, hence the latter setElement definition.
In the remainder of the program, I need to find innerPair regardless of their group ID so I basically need a function
std::set<setElement>::iterator find(innePair);
that will find the innerPair regardless of its group ID. As it stands I could simply cycle through all available group ID and do multiple find() calls, but it is far from efficient.
Is there a concise way of defining a find( ... ) member function that perform some sort of wildcarded search, or do I need to overload it with my own definition?
If you have multiple elements with the same inner pair and a differing group id, you could use
std::multimap<innerPair, int>.This allows you to store multiple elements with the same
innerPair.It also simplifies searching with
lower_bound/upper_boundorequal_range.