Could someone please provide me some examples of iterating through a
multimap. I wish to do the following
1. Iterate through each key in the multimap
2. For each key i find get all the possible values out so I can check
each value
Cheers
1. Iterate through all elements in the multimap<K,V>
2. create a map<K, set<V> > and fill the set with all the values found
Something along this:
multimap<K, V> mm;
map<K, vector<V> > values;
for(it = mm.begin(); it != mm.end(); ++it
{
values[(*it).first].insert((*it).second);
}
HTH
Stefan
--
Stefan Naewe
naewe.s_AT_atlas_DOT_de
If you iterate from begin() to end(), you'll get the key-value pairs in
order. You'll get each key multiple consecutive times, once for each of
its values. Note that the values won't necessarily come in any
particular order (e.g. not necessarily in insertion order).
If this isn't particularly useful to you, you could use a
map<key, vector<value> > or map<key, list<value> >
instead.
Tom