Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Ordering of same value keys in multimap

Thread Tools

Re: Ordering of same value keys in multimap

Howard Hinnant
Posts: n/a
On Sunday, August 26, 2012 9:36:50 AM UTC-4, Chris Vine wrote:

> If two or more pairs are added to a multimap which have the same
> key value, is there any requirement in the standard that when iterated
> through they should appear in the order in which they were inserted?
> Or is any ordering of same value keys OK, so this an implementation
> matter?

It depends on which standard.

In C++98/03, the ordering for equivalent keys was unspecified.

In C++11, this paper:
was adopted which specifies that if the keys are inserted without a hint, that they will be stored in the order that they were inserted. If they are inserted with a hint, then they will be positioned as close to the hint as possible. For example if the hint is end(), then they are always ordered in the order inserted. If the hint is always begin(), they are ordered in the reverse order inserted.

N1780 was adopted long enough ago, that I would expect all compiler/libraries to have already implemented it, whether or not operating in C++11 mode.
Reply With Quote
Howard Hinnant
Posts: n/a
On Monday, August 27, 2012 8:30:52 AM UTC-4, Chris Vine wrote:
> On Sun, 26 Aug 2012 11:56:28 -0700 (PDT)
> Also, I wonder if Table 102 is defective
> and it ought to distinguish between a_uniq.emplace_hint() and
> a_eq.emplace_hint() rather than lump them as a single item.

After distinguishing the entries, what changes would you make that makes them different?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ordering of hashtable keys Boris Punk Java 6 07-19-2010 04:20 AM
Z-Ordering (Morton ordering) question nbigaouette C Programming 2 11-06-2009 05:26 AM
copy from keys from multimap into the vector puzzlecracker C++ 19 10-30-2008 05:27 PM
stl multimap, insert with duplicate keys, is ordering stable? reppisch C++ 6 06-19-2007 09:38 AM
Distinct keys in the multimap Przemek C++ 3 01-31-2005 05:33 PM