-
September 2nd, 2010, 12:00 AM
#1
A question regarding multimap
There is one key having multiple values in a multimap. If I want to erase just one value corresponding to this key, how can I do that? If I can't do that, what is more appropriate data structure to use if I want to dynamically change the values associated with a key?
-
September 2nd, 2010, 12:51 AM
#2
Re: A question regarding multimap
You can use the version of the erase member function that takes an iterator to the element that you wish to erase.
-
September 2nd, 2010, 01:46 AM
#3
Re: A question regarding multimap
Originally Posted by laserlight
You can use the version of the erase member function that takes an iterator to the element that you wish to erase.
It works. Thanks.
-
September 2nd, 2010, 01:55 AM
#4
Re: A question regarding multimap
Depending on your design, if what you want are "several values associated to 1 key", rather than "several key-value pairs with the same key", then a "map<key, container<values>>" could be a better alternative.
But it's apples and oranges.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|