I’ve got a multimap<pair<string,string>,vector> > mmap;
and I would like to iterate over it with two loops:
- on the first element of the key:
key.first - then
key.second
Does the equal_range method work in this case?
How to write it?
pair<multimap<pair<string,string>,vector>::iterator,
multimap<pair<string,string>,vector>::iterator> key_range = mmap.equal_range( ?? );
multimaponly supports a single ordering, which forpairwould be by default the lexicographical ordering over two elements:If you need to index by two different keys you’re best off using another container e.g. Boost.MultiIndex. You could achieve the same effect yourself by e.g. storing items in a
listand holding maps from a key to list iterators: