2 ms·
Java can do it without too much trouble, you just have a version number on the collection that gets incremented with every mutation, and the iterator just check
by bmm6o 13y ago
Java can do it without too much trouble, you just have a version number on the collection that gets incremented with every mutation, and the iterator just checks to see if that has changed. C++ is much more complicated, allowing patterns like map.erase(i++) being legal but similar usages not.