Sign in to follow this  

stl map question

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Couple of ways, you can use the index operator:

mymap[key]

the problem here is: if there is no element with the key "key" then it will create one with a default value.

mapiterator = mymap.find(key);

this will return an iterator to the entry with the key "key", or to mymap.end() should it not exist.

Share this post


Link to post
Share on other sites
Maps are sorted. Unless you added the elements in a sorted order, you can't access the n'th element inserted. You could iterate over the map to the n'th element in the map.

Share this post


Link to post
Share on other sites

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this