public class MutableIterator2<E> extends Object implements Iterator<E>, Iterable<E>
Iterator
behaving like a FIFO queue.
Adheres to the general contract of the Iterator
, but is at the
same Iterable
so as to enable instances to work directly in
foreach loops in an attempt to make the client's code a little cleaner.
This class offers methods to safely append items to the iterator while the
iteration is ongoing. It also works directly on the collections added, which
should yield runtime improvements over MutableIterator
.
However, this class is still not ideal for the Combiner's split
queue (for which it was designed in the first place) because it only accepts
collections. What we really want is a Collection
that
offers an iterator that is safe to use (single-threadedly) while the
collection is being modified.
:TODO:
Constructor and Description |
---|
MutableIterator2() |
MutableIterator2(Collection<E> collection) |
Modifier and Type | Method and Description |
---|---|
void |
add(Collection<E> collection) |
void |
close() |
boolean |
hasNext() |
Iterator<E> |
iterator() |
static void |
main(String[] args) |
E |
next() |
void |
remove() |
void |
remove(E item) |
int |
size() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
forEach, spliterator
public MutableIterator2()
public MutableIterator2(Collection<E> collection)
public void add(Collection<E> collection)
public void close()
public int size()
public void remove(E item)
public static void main(String[] args)