com.generationjava.collections
Class CachingIterator
java.lang.Object
|
+--com.generationjava.collections.CachingIterator
- All Implemented Interfaces:
- java.util.Iterator, ResetableIterator
- public class CachingIterator
- extends java.lang.Object
- implements ResetableIterator
A piping Iterator which caches all objects that pass through it.
When reset is called, it returns to the start of its cache.
This however only allows for one version of the iterator at a time
to be used. It gets used again and again.
The alternative is to use the static cache method, or the iterate
method. Both of which may be used to get a new Iterator over the
same data.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CachingIterator
public CachingIterator(java.util.Iterator iterator)
next
public java.lang.Object next()
- Specified by:
next in interface java.util.Iterator
hasNext
public boolean hasNext()
- Specified by:
hasNext in interface java.util.Iterator
remove
public void remove()
- Specified by:
remove in interface java.util.Iterator
loadCache
public void loadCache()
- Force a loading of the wrapped iterator into cache.
reset
public void reset()
- Specified by:
reset in interface ResetableIterator
iterate
public java.util.Iterator iterate()
Copyright © 2000-2003 OSJava. All Rights Reserved.