There are many important differences between multimap<x, y>
and map<x, vector<y>>
After you have inserted the value in multimap, you know that the iterator will remain valid until you delete it, and this is a very strong property, you cannot have it with a vector map.
multimap<x,y>::iterator p=mymap.insert(make_pair(a,b));
The iterator remains valid until it is removed from the map, and in the second case, it will be invalidated every time you add a new record to the vector.
Also note that map<x, vector<y>>
may have null values ββset with an existing key, whereas multimap does not.
These are different things that behave differently.
And frankly, I skip multimap in some languages ββthat don't provide it in my library.
Artyom Dec 14 '10 at 12:34
source share