| java.lang.Object net.sf.jga.util.CachingIterator
CachingIterator | public class CachingIterator implements Iterator<T>,Iterable<T>(Code) | | Iterator that allows the program to retain the last few elements returned.
Copyright © 2003-2005 David A. Hall
author: David A. Hall |
Constructor Summary | |
public | CachingIterator(Iterator<? extends T> base) Builds a CachingIterator that can retain 1 element. | public | CachingIterator(Iterator<? extends T> base, int max) Builds a CachingIterator that can retain the given number of elements. |
Method Summary | |
public T | cached(int n) Returns the Nth previous element consumed from the underlying iterator. | public int | getCacheCount() | public int | getCacheSize() | public boolean | hasCached(int n) Returns true if there have been at least N elements consumed from the
underlying iterator. | public boolean | hasNext() | public Iterator<T> | iterator() | public T | next() | public void | remove() Removes the last item returned from the base iterator, if the base
iterator supports the remove operation. |
CachingIterator | public CachingIterator(Iterator<? extends T> base)(Code) | | Builds a CachingIterator that can retain 1 element.
|
CachingIterator | public CachingIterator(Iterator<? extends T> base, int max)(Code) | | Builds a CachingIterator that can retain the given number of elements.
throws: IllegalArgumentException - if max <= 0. |
cached | public T cached(int n)(Code) | | Returns the Nth previous element consumed from the underlying iterator.
|
getCacheCount | public int getCacheCount()(Code) | | Returns the number of elements in the cache
|
getCacheSize | public int getCacheSize()(Code) | | Returns the cache size
|
hasCached | public boolean hasCached(int n)(Code) | | Returns true if there have been at least N elements consumed from the
underlying iterator.
|
hasNext | public boolean hasNext()(Code) | | |
remove | public void remove()(Code) | | Removes the last item returned from the base iterator, if the base
iterator supports the remove operation. The item is not removed from
the cache.
throws: UnsupportedOperationException - if the base iterator does notsupport the remove() operation |
|
|