public class CloneIterator<E> extends java.lang.Object implements IterableIterator<E>
CloneIterator iterates over a copy of a collection, allowing for concurrent access
to the original collection.
The original collection passed to the CloneIterator's constructor should be
synchronized; otherwise you run the risk of a corrupted collection.
By default, a CloneIterator does not support the remove() operation; this
is because it does not have access to the original collection. But if the CloneIterator
is supplied with an Mutator it will delegate the remove() operation to the
Mutator. Alternatively, a subclass can override the remove(Object) method.
| Constructor and Description |
|---|
CloneIterator(java.util.Collection<? extends E> collection)
Creates a new
CloneIterator using a copy of the specified collection. |
CloneIterator(java.util.Collection<? extends E> collection,
Mutator<? extends E> mutator)
Creates a new
CloneIterator using a copy of the specified collection. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
java.util.Iterator<E> |
iterator() |
E |
next() |
void |
remove() |
java.lang.String |
toString() |
public CloneIterator(java.util.Collection<? extends E> collection)
CloneIterator using a copy of the specified collection. The remove() method will not be supported, unless a subclass overrides remove(Object).collection - The collection that is copied in order to iterate over its items without
being changed concurrentlypublic CloneIterator(java.util.Collection<? extends E> collection, Mutator<? extends E> mutator)
CloneIterator using a copy of the specified collection. Use the
specified mutator to remove objects from the original collection.collection - The collection that is copied in order to iterate over its items without
being changed concurrentlymutator - This Mutator is used to remove the item from the original collectionpublic boolean hasNext()
hasNext in interface java.util.Iterator<E>public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>public void remove()
remove in interface java.util.Iterator<E>public java.lang.String toString()
toString in class java.lang.ObjectEclipseLink 2.4.2, "build v20130514-5956486" API Reference