Package org.apache.jena.atlas.iterator
Class IteratorWithHistory<T>
- java.lang.Object
-
- org.apache.jena.atlas.iterator.IteratorWithHistory<T>
-
- All Implemented Interfaces:
java.util.Iterator<T>
public class IteratorWithHistory<T> extends java.lang.Object implements java.util.Iterator<T>Remembers the last N yields. See alsoIteratorWithBuffer, for an iterator that looks ahead to what it will yield.- See Also:
IteratorWithBuffer,PeekIterator,PushbackIterator
-
-
Constructor Summary
Constructors Constructor Description IteratorWithHistory(java.util.Iterator<T> iter, int N)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcurrentSize()Return the current size of the history.TgetPrevious(int idx)return the previous i'th element returned by next().booleanhasNext()Tnext()
-
-
-
Constructor Detail
-
IteratorWithHistory
public IteratorWithHistory(java.util.Iterator<T> iter, int N)
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<T>
-
getPrevious
public T getPrevious(int idx)
return the previous i'th element returned by next(). 0 means last call of next. History is retained after the end of iteration.- Returns:
- Element or null for no such element (that is for haven't yielded that many elements).
- Throws:
java.lang.IndexOutOfBoundsException- if index is negative.
-
currentSize
public int currentSize()
Return the current size of the history. This can be used to tell the difference between an iterator returning null and an iterator that is just short.
-
-