deleting a value from multimap

Jonathan Wakely jwakely.gcc@gmail.com
Thu Dec 1 17:47:00 GMT 2011


On 1 December 2011 16:08, mahadev wrote:
>
> mahadev wrote:
>>
>> Hi all,
>>
>> my requirement is to delete a "value" from a multimap regardless of the
>> "key".
>> For ex:
>>    multimap<string, int> fruits;
>>    fruits.insert(pair<string, int>("apple",1));
>>    fruits.insert(pair<string, int>("apple",2));
>>
>>    fruits.insert(pair<string, int>("cherry",1));
>>    fruits.insert(pair<string, int>("cherry",3));
>>
>> I want to delete the value "1"  whether the key ="apple" or "cherry".
>> After deletion "apple" should have only "2" as its value;i.e i need to
>> delete only the "value" and not the "key"
>>
>> I tried "erase()", but even after erasing, i am able to print the values.
>>
>> Thanks,
>> Vasavi
>>
>>
>>

Please try to quote properly, it makes it easier for everyone to read your mail.

I have no idea what you mean by "I tried erase()", if you want people
to help you need to explain properly what you're doing, preferably
with a complete example.  But as Chris said, this is the wrong mailing
list for such questions, you should try gcc-help or a C++ forum.



More information about the Libstdc++ mailing list