com.generationjava.collections
Class CachingIterator

java.lang.Object
  extended bycom.generationjava.collections.CachingIterator
All Implemented Interfaces:
Iterator, ResetableIterator

public class CachingIterator
extends 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.


Constructor Summary
CachingIterator(Iterator iterator)
           
 
Method Summary
 boolean hasNext()
           
 Iterator iterate()
           
 void loadCache()
          Force a loading of the wrapped iterator into cache.
 Object next()
           
 void remove()
           
 void reset()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingIterator

public CachingIterator(Iterator iterator)
Method Detail

next

public Object next()
Specified by:
next in interface Iterator

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator

remove

public void remove()
Specified by:
remove in interface 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 Iterator iterate()


Copyright © 2000-2005 OSJava. All Rights Reserved.