J
John Mills
Hello -
I'm using STL's 'multimap' type and wish to remove multimap entries for
which 'second' matches some test, roughly as follows:
multimap<type1, type2> mm;
multimap<type1, type2>::iterator pos;
...
for(pos = mm.begin(); pos != mm.end(); ++pos)
if (mytest(pos->second)) {
mm.erase(pos);
break;
}
...
This _should_ work because I expect only one matching map entry at any one
time, but I wondered how to keep looking for more matches, _after_ having
erased the element at 'pos'. Is the iterator still useful after my
'erase'? (My reference says the multimap 'erase' is of type 'void', unlike
[say] for a vector.)
TIA from a Newbie.
- John Mills
(e-mail address removed)
I'm using STL's 'multimap' type and wish to remove multimap entries for
which 'second' matches some test, roughly as follows:
multimap<type1, type2> mm;
multimap<type1, type2>::iterator pos;
...
for(pos = mm.begin(); pos != mm.end(); ++pos)
if (mytest(pos->second)) {
mm.erase(pos);
break;
}
...
This _should_ work because I expect only one matching map entry at any one
time, but I wondered how to keep looking for more matches, _after_ having
erased the element at 'pos'. Is the iterator still useful after my
'erase'? (My reference says the multimap 'erase' is of type 'void', unlike
[say] for a vector.)
TIA from a Newbie.
- John Mills
(e-mail address removed)