net.cscott.jutil
Class SnapshotIterator<E>
java.lang.Object
net.cscott.jutil.UnmodifiableIterator<E>
net.cscott.jutil.SnapshotIterator<E>
- All Implemented Interfaces:
- Iterator<E>
- Direct Known Subclasses:
- ReverseIterator
public class SnapshotIterator<E>
- extends UnmodifiableIterator<E>
A SnapshotIterator takes a "snapshot" of an iterator,
and iterates over that snapshot. So subsequent modifications to
the collection underlying the original iterator do not modify the
snapshot or the SnapshotIterator. This is very
useful for modifying collections via a visitor class: we want
to make sure that every element of the original collection is
visited, while still permitting the visitor to make changes to
the collection as it operates.
- Version:
- $Id: SnapshotIterator.java,v 1.3 2006-10-30 19:58:07 cananian Exp $
- Author:
- C. Scott Ananian
|
Method Summary |
boolean |
hasNext()
Returns true if the iteration has more elements. |
E |
next()
Returns the next element in the iteration. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SnapshotIterator
public SnapshotIterator(Iterator<E> it)
- Creates a
SnapshotIterator from Iterator
it.
hasNext
public boolean hasNext()
- Description copied from class:
UnmodifiableIterator
- Returns
true if the iteration has more elements.
- Specified by:
hasNext in interface Iterator<E>- Specified by:
hasNext in class UnmodifiableIterator<E>
- Returns:
true if the iterator has more elements.
next
public E next()
- Description copied from class:
UnmodifiableIterator
- Returns the next element in the iteration.
- Specified by:
next in interface Iterator<E>- Specified by:
next in class UnmodifiableIterator<E>
Copyright (c) 2006 C. Scott Ananian