finding value in a multimap

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


On 1 December 2011 16:15, mahadev wrote:
>
> mahadev wrote:
>>
>> hi all,
>>
>> can i use "find()" to find a "value" in the multimap.
>>
>> For ex:
>> multimap<char,int> mymm;
>> mymm.insert (pair<char,int>('x',10));
>> if (mymm.find(10) != mymm.end())   {
>>     -------
>> }
>>
>>  i am using find method to find a "value" and not the "key"
>> Does this work? If not, i kindly request you to suggest me a way to do so.

Please stop emailing basic questions to this mailing list - this is
not the right place to ask how to use C++.

No, it doesn't work, your find(10) will find a key with value char(10).

As Chris told you already, you need to iterate through every element
of the map and inspect the values in order to find the elements you
want to delete.



More information about the Libstdc++ mailing list