Class CloneIterator<E>
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.utility.iterator.CloneIterator<E>
-
- Type Parameters:
E
- the type of elements returned by the iterator
- All Implemented Interfaces:
Iterator<E>
public class CloneIterator<E> extends Object implements Iterator<E>
ACloneIterator
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 (e.g.Vector
); otherwise you run the risk of a corrupted collection.By default, a
CloneIterator
does not support theremove()
operation; this is because it does not have access to the original collection. But if theCloneIterator
is supplied with anCloneIterator.Remover
it will delegate theremove()
operation to theCloneIterator.Remover
. Alternatively, a subclass can override theremove(Object)
method.- See Also:
- LiveCloneIterable, SnapshotCloneIterable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CloneIterator.Remover<T>
Used byCloneIterator
to remove elements from the original collection; since the iterator does not have direct access to the original collection.
-
Constructor Summary
Constructors Constructor Description CloneIterator(E[] array)
Construct an iterator on a copy of the specified array.CloneIterator(E[] array, CloneIterator.Remover<E> remover)
Construct an iterator on a copy of the specified array.CloneIterator(Collection<? extends E> collection)
Construct an iterator on a copy of the specified collection.CloneIterator(Collection<? extends E> collection, CloneIterator.Remover<E> remover)
Construct an iterator on a copy of the specified collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
E
next()
void
remove()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
CloneIterator
public CloneIterator(Collection<? extends E> collection)
Construct an iterator on a copy of the specified collection. Theremove()
method will not be supported, unless a subclass overrides theremove(Object)
.
-
CloneIterator
public CloneIterator(E[] array)
Construct an iterator on a copy of the specified array. Theremove()
method will not be supported, unless a subclass overrides theremove(Object)
.
-
CloneIterator
public CloneIterator(Collection<? extends E> collection, CloneIterator.Remover<E> remover)
Construct an iterator on a copy of the specified collection. Use the specified remover to remove objects from the original collection.
-
CloneIterator
public CloneIterator(E[] array, CloneIterator.Remover<E> remover)
Construct an iterator on a copy of the specified array. Use the specified remover to remove objects from the original array.
-
-