3 ms·
Deleting From A Collection in STL is hard
- echaozh 16y agoIf I have to iterate over all the objects in a container and erase some of them, I always push the keys/indices into another deque first. And then the deque is iterated through to remove those items from the original set (in the reverse order in the case of a vector). I'm not very confident in the validity of iterators.