473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

is STL multimap "find" order stable?

#include <map>
#include <iostream>

using namespace std;

int main(
int argc,
const char * argv[]
)
{
if( 4 != argc ) {
cerr << "usage: " << endl
<< argv[0] << " index value1 value2" << endl;
exit(1);
}
int index = atoi(argv[1]);
int value1 = atoi(argv[2]);
int value2 = atoi(argv[3]);
multimap<int,int> mm;
mm.insert( pair<int,int>(index,value1) );
mm.insert( pair<int,int>(index,value2) );
cout << "Am I guaranteed that " << mm.find(index)->second << " == "
<< value1 << "?" << endl;
return 0;
}

I have read the STL docs and I did not see this explicitly stated.

Jul 23 '05 #1
4 3206
There's no guarantee about the order of identical keys in a multimap.

Jul 23 '05 #2
Arg... that is very unfortunate. I might actually have to write some
code :(
Thanks for the info.

Jul 23 '05 #3
In article <11*********************@g44g2000cwa.googlegroups. com>,
sa************@gmail.com wrote:
Arg... that is very unfortunate. I might actually have to write some
code :(
Thanks for the info.


Fwiw, I'm trying to change this, at least partly:

http://www.open-std.org/jtc1/sc22/wg...005/n1780.html

If accepted, you would have to use lower_bound instead of find, but
otherwise you would be good to go. But as James said, as it stands
today you're just out of luck as far as the standard goes.

However the above paper contains a survey of several libraries (actually
all of them (current versions) that I'm aware of), and they all
implement "insert without hint" as if they were told to "insert at
upper_bound". So from a practical standpoint you might get away with
use of lower_bound instead of find today.

-Howard
Jul 23 '05 #4
Howard, thanks so much!
This paper does all the hard work. It is sufficient for me to know that
current implementations are stable when inserting without hints. I will
just add additional unit tests to be sure it doesn't bite me when
someone changes the implementation.
Best wishes,
Salem

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jaime Wyant | last post by:
Will someone explain this to me? >>> "test".find("") 0 Why is the empty string found at position 0? Thanks! jw
3
by: David | last post by:
Hi, I want to do a query that displays duplicate records in the database based on IP address. What syntax should I use in the WHERE********** bit please? Thanks, set rsData =...
1
by: Galsaba | last post by:
Anyone knows how I can find a script for "Find a Dealer near you" locator script? I prefer to have it in two stages: 1. The customer will enter his address, and then the result will be a list of...
1
by: Galsaba | last post by:
I am trying to find a script to a "dealer locator" or "find a store near you". I will have two tables. One will include all US and Canada ZIPs including lat and longtitudes. The other one is a...
2
by: Praveen | last post by:
In the ISPF editor I am using, for a particullar PO Dataset I am getting the result of FIND statement narrowed down to the colums 48-56. i.e. if I give "FIND 'TO' ALL", the result I am getting as...
3
by: Dmitry Jouravlev | last post by:
Hi, I have a number of C++ solutions in Visual Studio .NET and when i compile them using "Whole Program Optimization", certain projects report a LNK1171 error saying that c2.dll could not be...
2
by: Lenonardo | last post by:
Hi. I'm writing a VB.Net application to update multiple Excel Worksheets. I'm using late binding (i.e. all variables are objects + use createobject) I develop the application on an XP...
3
by: OJ | last post by:
Hi, I have added code to run on a button click event which adds usercontrols to an asp:Panel control held in a contentplaceholder defined by the masterpage. for (int x = 0; x <...
0
by: Rave | last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.