This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: deleting a value from multimap
- From: Christopher Jefferson <caj21 at st-andrews dot ac dot uk>
- To: mahadev <vasavi dot mahadev at polycom dot com>
- Cc: "<libstdc++ at gcc dot gnu dot org>" <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 1 Dec 2011 16:02:00 +0000
- Subject: Re: deleting a value from multimap
- References: <32894799.post@talk.nabble.com>
On 1 Dec 2011, at 15:58, 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"
This is really more of a question for gcc-help, or a general C++ help mailing list.
There is no efficient method of doing this, you will have to iterate through the whole multimap, looking for such elements. I will leave it up to you to iterate through the multimap and delete certain elements.
Chris
>
> Thanks,
> Vasavi
>
>
> --
> View this message in context: http://old.nabble.com/deleting-a-value-from-multimap-tp32894799p32894799.html
> Sent from the gcc - libstdc++ mailing list archive at Nabble.com.
>