Once you call map.erase(iterator) the iterator will be invalidated. What you need to do is something like:
for(iterator=map.begin(); iterator != map.end(); )
{
del_iterator = iterator;
iterator++;
map.erase(del_iterator);
}
for(iterator=map.begin(); iterator != map.end(); )
{
del_iterator = iterator;
iterator++;
map.erase(del_iterator);
}
No comments:
Post a Comment