472,328 Members | 1,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

map::insert gets a hint. What about map::find?

I'm often find-ing the same string in a map<string,xxx>

I want to pass a hint to map::find but was disappointed to find that
only map::insert takes the hint.

Why would map::insert take a hint but not map::find?

Thanks,

Rudy

Jul 23 '05 #1
3 3708
ru*******@hotmail.com wrote:
I'm often find-ing the same string in a map<string,xxx>

I want to pass a hint to map::find but was disappointed to find that
only map::insert takes the hint.

Why would map::insert take a hint but not map::find?


If you already have an iterator to the element, there is no point in using
find.

Jul 23 '05 #2
>If you already have an iterator to the element, there is no point in

I do not already have an iterator to the element. I know my example
seems to indicate I do, but the actualy case is much to complicated to
post here. Plus it's irrelevent to my question:

Why would map::insert take a hint but not map::find?

Jul 23 '05 #3
In article <11**********************@l41g2000cwc.googlegroups .com>,
ru*******@hotmail.com wrote:
If you already have an iterator to the element, there is no point in


I do not already have an iterator to the element. I know my example
seems to indicate I do, but the actualy case is much to complicated to
post here. Plus it's irrelevent to my question:

Why would map::insert take a hint but not map::find?


Perhaps we didn't think of it. Or perhaps it is too easy to do
something like:

if (guess->first != key)
guess == m.find(key);
// guess now points to either key or end()

A key question is: For the semantics you desire, can it be done more
efficiently internal to map than you can do externally? Or is such an
external implementation sufficiently complicated that it is likely that
clients will get it wrong? If the answer is no, then adding such
functionality would merely be a convenience function and bloat the
interface with dubious benefit (see std::string). If the answer is yes,
then you likely have a good point, and I would like to see a proposal
before the LWG immediately (time grows short for C++0X).

The "insert with hint" functionality as currently specified is also of
dubious usefulness, and I hope to make it more useful for C++0X. There
will be a paper in the post-Lillehammer mailing addressing this issue.

-Howard
Jul 23 '05 #4

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

Similar topics

4
by: Matthias Hildebrand | last post by:
Hello, std::map< int, MyClass*> mymap; it = mymap.find( somekey ) // here happen bad things if( it != mymap.end() ) { // do something useful...
2
by: David Loo | last post by:
Hi, I want to use a map to store a list of strings and i dont want a duplicate string added to the list. how can I go about this using the STL...
3
by: Manuel Maria Diaz Gomez | last post by:
Hi everybody, This should be trivial, but I just can't see it. The following statement in a method doesn't work for me: (there's only one entry...
5
by: EnTn | last post by:
Hi Everyone... I've been trying to use a std::map to do some storage. Basically, i'm storing double values using a Key Object. The Key object is...
5
by: Peter Jansson | last post by:
Hello, I have the following code: std::map<int,std::set<std::string> > k; k="1234567890"; k="2345678901"; //... std::set<std::string>...
2
by: cyndykoobs | last post by:
I have run into a problem that I cannot seem to figure out regarding a method call to STL map::find(). When the key value can't be found in the map...
6
by: Benny the Guard | last post by:
Been working on a project that compiles, links, and runs fine on 32-bit windows. Now trying to migrate to 64-bit windows. On debug build it works...
3
by: maheshr22 | last post by:
Hey Heres what i want to do: I want to create a map which has <string, vector<vector<int>>>. The string is always unique. What i need to do...
8
by: drjay1627 | last post by:
hello, This is my 1st post here! *welcome drjay* Thanks! I look answering questions and getting answers to other! Now that we got that...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.