Hi All,
I think that it is not legitimate to erase entries in a map in the following way:
The purpose is to transform the above code into one so that entries meeting a certain condition can be erased from map on one pass.Code:MyMap temp; //fill in temp here MyMap::iterator it; //MyMap is a typedef of STL map for(it = temp.begin(); it != temp.end(); it++) { if( condition ) { temp.erase(it->first); //erase by key } }
Thanks.




Reply With Quote