user612514
user612514

Reputation: 99

equal_range c++ element order

I am using multimap's equal range in C++. In my case there can be multiple entries for the same key - thus multimap. I wonder if the returned iterator will deliver the items in the defined order or is it left to the implemeter of the STL. For example, I will insert in the multimap the keys A B C D E F C X Y Z C M N A etc. and would like to know in which order the iterator will return me the atching keys. Order in which they have been inserted? last inserted first? not-defined? I try to avoid storing extra info just to know the order. In my case it is plain C++, not even C++11. Thanks, Victor

Upvotes: 0

Views: 298

Answers (1)

1201ProgramAlarm
1201ProgramAlarm

Reputation: 32732

The duplicate keys will be inserted after the existing keys, so the order of elements will be maintained (see "Associative containers" in the language spec).

Upvotes: 1

Related Questions