开发者

Will std::multimap preserve the insert order if the key of 2 elements equal to each other?

开发者 https://www.devze.com 2023-01-08 23:11 出处:网络
I am wondering whether this is true? If it is, is this behavior guaran开发者_如何学Pythonteed by the c++ standard?The elements in a std::map must have unique keys, so... no.

I am wondering whether this is true? If it is, is this behavior guaran开发者_如何学Pythonteed by the c++ standard?


The elements in a std::map must have unique keys, so... no.

The std::multimap container allows multiple values mapped to one key. When iterating over a std::multimap the elements are ordered by key, but the order of elements having the same key is not specified.

Note that in the latest draft of the forthcoming C++0x standard (N3092), the relative ordering of elements with the same key is guaranteed (so, at some point, you'll be able to rely on this behavior).

0

精彩评论

暂无评论...
验证码 换一张
取 消