net.sf.jga.util
public class LookAheadIterator<T> extends Object implements Iterator<T>
Copyright © 2003 David A. Hall
Constructor Summary | |
---|---|
LookAheadIterator(Iterator<? extends T> base)
Builds a LookAheadIterator that can look ahead 1 element. | |
LookAheadIterator(Iterator<? extends T> base, int max)
Builds a LookAheadIterator that can look ahead the given number of
elements.
|
Method Summary | |
---|---|
int | getMaxPeekSize()
Returns the maximum offset that may be peeked. |
boolean | hasNext() |
boolean | hasNextPlus(int n)
Returns true if there is an element at the Nth position. |
T | next() |
T | peek(int n)
Returns the element at the Nth position. |
void | remove() |
static <T> LookAheadIterator<T> | wrapIfNecessary(Iterator<? extends T> base, int max)
Creates a LookAheadIterator of the given size to wrap the given iterator,
if the given iterator isn't already of the proper type and size |
Throws: IllegalArgumentException if max <= 0.
Returns:
Returns: true if there is an element at the Nth position
Throws: IllegalArgumentException if n < 0 or n > max lookahead
Returns:
Returns: the element at the Nth position
Throws: IllegalArgumentException if n < 0 or n > max lookahead NoSuchElementException if the Nth position is off the end of the iteration