This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: finding value in a multimap
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: mahadev <vasavi dot mahadev at polycom dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 1 Dec 2011 17:50:16 +0000
- Subject: Re: finding value in a multimap
- References: <32895179.post@talk.nabble.com> <32895208.post@talk.nabble.com>
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.