Programming and animation
Programming and animation ideas, articles, tutors, scripts, plugins in the 3d
-
STL Vector & Map element removing
Posted on 17 August 2009 Neill No commentsThere is a small feature to be borne in mind when you remove an element in the vector and map.
Suppose there is such a situation, we start to cycle through the elements by iterator, and some of the criteria if the item is not suitable, it should be removed.
For a vector it will be as follows:1
2
3
4tempIter = Iter;
lVector.erase(Iter)
Iter = tempIter;
continue;For a map it will be as follows:
Programming C++, Map, STL, Tips, Vector1
2
3
4
5tempIter = Iter;
tempIter++;
lMap.erase(Iter)
Iter = tempIter;
continue;Leave a Reply
You must be logged in to post a comment.

English
Russian
Recent Comments