harpoon.Util
Class CloneableIterator
java.lang.Object
harpoon.Util.CloneableIterator
- All Implemented Interfaces:
- Cloneable, Iterator, ListIterator
public class CloneableIterator
- extends Object
- implements ListIterator, Cloneable
CloneableIterator is a wrapper around
Iterator that is safely Cloneable.
Essentially this and all of the clones of
this share the original Iterator and
maintain a shared list of objects, each keeping a pointer into
their current object in the shared list. If this or
one of its clones reaches the end of the shared list, it attempts
to add more elements onto the end of the list by extracting them
from the shared Iterator.
- Version:
- $Id: CloneableIterator.java,v 1.5 2004/02/08 01:56:15 cananian Exp $
- Author:
- Felix S. Klock II <pnkfelix@mit.edu>
CloneableIterator
public CloneableIterator(Iterator iter)
- Creates a
CloneableIterator using
iter as its source.
hasNext
public boolean hasNext()
- Specified by:
hasNext in interface Iterator- Specified by:
hasNext in interface ListIterator
next
public Object next()
- Specified by:
next in interface Iterator- Specified by:
next in interface ListIterator
nextIndex
public int nextIndex()
- Specified by:
nextIndex in interface ListIterator
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPrevious in interface ListIterator
previous
public Object previous()
- Specified by:
previous in interface ListIterator
previousIndex
public int previousIndex()
- Specified by:
previousIndex in interface ListIterator
clone
public CloneableIterator clone()
- Overrides:
clone in class Object
remove
public void remove()
- Specified by:
remove in interface Iterator- Specified by:
remove in interface ListIterator
add
public void add(Object o)
- Specified by:
add in interface ListIterator
set
public void set(Object o)
- Specified by:
set in interface ListIterator