If you create your own Iterable
container class and retrieve a java.util.Iterator
over its elements, is there any coding pattern according to which any further additions of elements in the container should not be accessible from the Iterator
? I'm thinking "no way, absolutely not, in fact the Iterator
should be able to loop through all of the elements regardless of additions."
Or is it perhaps the case that a fail-fast Iterator
should throw an Exception if next()
is called after a new addition is made?
Been a while since I've coded in Java yet something stinks here.