Topic: Order of equal keys in multi(set,map)


Author: John Aldridge <jpsa@jjdash.demon.co.uk>
Date: 1997/09/11
Raw View
A multiset or multimap can contain several entries with equivalent key
values.  I can't see anything in the draft standard which constrains the
order in which such equivalent entries are to be returned when
iterating.

For example, I'd hoped that

   someSet.insert (someIterator, someValue);

would be guaranteed to insert the new value immediately before the
supplied iterator, provided that position is consistent with the
ordering relation.

Likely uses are, for example

   someSet.insert (someSet.lower_bound (someValue), someValue);
   someSet.insert (someSet.upper_bound (someValue), someValue);

to insert new values at the beginning or end of any existing run.

I can't even find a guarantee that the iteration order is 'stable', in
the sense that the container may not arbitrarily re-order runs of
equivalent keys when it feels like it.

Have I missed something, or is this behaviour intentionally left
undefined?
--
Cheers,
John
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]