| java.lang.Object net.sf.jga.util.LookAheadIterator
LookAheadIterator | public class LookAheadIterator implements Iterator<T>,Iterable<T>(Code) | | Iterator that allows the program to look at and operate on the next few
elements without consuming them.
Copyright © 2003-2005 David A. Hall
author: David A. Hall |
Constructor Summary | |
public | LookAheadIterator(Iterator<? extends T> base) Builds a LookAheadIterator that can look ahead 1 element. | public | LookAheadIterator(Iterator<? extends T> base, int max) Builds a LookAheadIterator that can look ahead the given number of
elements. |
Method Summary | |
public int | getMaxPeekSize() Returns the maximum offset that may be peeked. | public boolean | hasNext() | public boolean | hasNextPlus(int n) Returns true if there is an element at the Nth position. | public Iterator<T> | iterator() | public T | next() | public T | peek(int n) Returns the element at the Nth position. | public void | remove() |
LookAheadIterator | public LookAheadIterator(Iterator<? extends T> base)(Code) | | Builds a LookAheadIterator that can look ahead 1 element.
|
LookAheadIterator | public LookAheadIterator(Iterator<? extends T> base, int max)(Code) | | Builds a LookAheadIterator that can look ahead the given number of
elements.
throws: IllegalArgumentException - if max <= 0. |
getMaxPeekSize | public int getMaxPeekSize()(Code) | | Returns the maximum offset that may be peeked.
|
hasNext | public boolean hasNext()(Code) | | |
hasNextPlus | public boolean hasNextPlus(int n)(Code) | | Returns true if there is an element at the Nth position. Put another
way, returns true if there are enough elements remaining in the iterator
that next() could be called N times without having a
NoSuchElementException thrown.
true if there is an element at the Nth position throws: IllegalArgumentException - if n < 0 or n > max lookahead |
peek | public T peek(int n)(Code) | | Returns the element at the Nth position. Put another way, returns the
element that the Nth call to next() would return. The current position
of the iteration is not modified.
the element at the Nth position throws: IllegalArgumentException - if n < 0 or n > max lookahead throws: NoSuchElementException - if the Nth position is off the end ofthe iteration |
remove | public void remove()(Code) | | |
|
|