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 (e.g. java.);
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 Remover it will delegate the
remove() operation to the Remover.
Alternatively, a subclass can override the remove(Object)
method.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | CloneIterator.Remover<T>
Used by |
| Modifier and Type | Field and Description |
|---|---|
| private E | |
| private final Iterator | |
| private boolean | |
| private final CloneIterator. |
| Access | Constructor and Description |
|---|---|
| public | CloneIterator(Collection<? extends E> collection)
Construct an iterator on a copy of the specified collection. |
| public | |
| public | CloneIterator(Collection<? extends E> collection, CloneIterator.
Construct an iterator on a copy of the specified collection. |
| public | CloneIterator(E[] array, CloneIterator.
Construct an iterator on a copy of the specified array. |
| protected | CloneIterator(CloneIterator.
Internal constructor used by subclasses. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| protected E | nestedNext()
The collection passed in during construction held elements of type |
| public E | |
| public void | remove()
Overrides default java. |
| protected void |
| current | back to summary |
|---|---|
| private E current | |
| iterator | back to summary |
|---|---|
| private final Iterator<Object> iterator | |
| removeAllowed | back to summary |
|---|---|
| private boolean removeAllowed | |
| remover | back to summary |
|---|---|
| private final CloneIterator. | |
| CloneIterator | back to summary |
|---|---|
| public CloneIterator(Collection<? extends E> collection) Construct an iterator on a copy of the specified collection.
The | |
| CloneIterator | back to summary |
|---|---|
| public CloneIterator(E[] array) Construct an iterator on a copy of the specified array.
The | |
| CloneIterator | back to summary |
|---|---|
| public CloneIterator(Collection<? extends E> collection, CloneIterator. Construct an iterator on a copy of the specified collection. Use the specified remover to remove objects from the original collection. | |
| CloneIterator | back to summary |
|---|---|
| public CloneIterator(E[] array, CloneIterator. Construct an iterator on a copy of the specified array. Use the specified remover to remove objects from the original array. | |
| CloneIterator | back to summary |
|---|---|
| protected CloneIterator(CloneIterator. Internal constructor used by subclasses. Swap order of arguments to prevent collision with other constructor. The passed in array will *not* be cloned. | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| nestedNext | back to summary |
|---|---|
| protected E nestedNext() The collection passed in during construction held elements of type
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |
| remove | back to summary |
|---|---|
| protected void remove(E e) Remove the specified element from the original collection.
This method can be overridden by a subclass as an
alternative to building a | |
CloneIterator to remove
elements from the original collection; since the iterator
does not have direct access to the original collection.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| remove | back to summary |
|---|---|
| public void remove(T element) Remove the specified object from the original collection. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final CloneIterator. | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static <R> CloneIterator. | |
| private Object | |
| public void | remove(Object element)
Implements org. |
| INSTANCE | back to summary |
|---|---|
public static final CloneIterator.
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ReadOnly | back to summary |
|---|---|
| private ReadOnly() | |
| instance | back to summary |
|---|---|
public static <R> CloneIterator.
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
| remove | back to summary |
|---|---|
| public void remove(Object element) Implements org. Doc from org. Remove the specified object from the original collection.
| |