Open 981377660LMT opened 1 year ago
You can not remove elements while you are using a iterator. You will make the iterator become invalid, then any operation on the iterator will cause a problem.
FWIW, when you use an iterator over a collection in Java, the returned iterator supports deleting the most recently returned element. Might be an acceptable way to support deletion during iteration? https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#remove--
I think that after removing an element, the iterators of the other elements need to be unaffected.