This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: finding value in a multimap


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]