net.cscott.jutil

Class SnapshotIterator<E>

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.1 2003/03/20 01:58:20 cananian Exp $

Author: C. Scott Ananian

Constructor Summary
SnapshotIterator(Iterator<E> it)
Creates a SnapshotIterator from Iterator it.
Method Summary
booleanhasNext()
Enext()

Constructor Detail

SnapshotIterator

public SnapshotIterator(Iterator<E> it)
Creates a SnapshotIterator from Iterator it.

Method Detail

hasNext

public boolean hasNext()

next

public E next()
Copyright © 2003 C. Scott Ananian