|
Boost Users : |
Subject: Re: [Boost-users] Correct use of unordered_map
From: Nat Goodspeed (nat_at_[hidden])
Date: 2009-08-31 20:56:18
Richard Hadsell wrote:
>> I use one of these 2 ways:
>>
>> for (my_map_t::iterator it= my_map.begin(); it != end; ) {
>> if (is_to_be_removed(it->first))
>> it = global_map.erase (it);
>> else
>> ++it;
>> }
>>
>> for (my_map_t::iterator it= my_map.begin(); it != end; ) {
>> my_map_t::iterator itx = it++;
>> if (is_to_be_removed(itx->first))
>> global_map.erase (itx);
>> }
> I should add that the second way is useful, when you are not executing
> 'erase' but rather some arbitrary code that may or may not actually
> erase the element from the container.
nod
I can't resist pointing out Scott Meyers's "Effective STL," Item 9, p.
43: "Choose carefully among erasing options." :-)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net