org.openjena.atlas.iterator
Class IteratorWithHistory<T>

java.lang.Object
  extended by org.openjena.atlas.iterator.IteratorWithHistory<T>
All Implemented Interfaces:
Iterator<T>

public class IteratorWithHistory<T>
extends Object
implements Iterator<T>

Remembers the last N yields. See also IteratorWithBuffer, for an iterator that looks ahead to what it wil yield.

See Also:
IteratorWithBuffer, PeekIterator, PushbackIterator

Constructor Summary
IteratorWithHistory(Iterator<T> iter, int N)
           
 
Method Summary
 int currentSize()
          Return the current size of the histiory.
 T getPrevious(int idx)
          return the previous i'th element returned by next().
 boolean hasNext()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorWithHistory

public IteratorWithHistory(Iterator<T> iter,
                           int N)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

next

public T next()
Specified by:
next in interface Iterator<T>

remove

public void remove()
Specified by:
remove in interface 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:
IndexOutOfBoundsException - if index is negative.

currentSize

public int currentSize()
Return the current size of the histiory. This can be used to tell the difference between an iterator returning null and an iterator that is just short.



Licenced under the Apache License, Version 2.0