4 ms·
If 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
by echaozh 16y ago
If 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.