Iterator interface for sequences
whose next element can always be derived from the previous element. Null elements are not
supported, nor is the remove() method.
Example:
Iterator<Integer> powersOfTwo =
new AbstractSequentialIterator<Integer>(1) {
protected Integer computeNext(Integer previous) {
return (previous == 1 << 30) ? null : previous * 2;
}
};
AbstractLinkedIterator since 8.0)
| Modifier and Type | Field and Description |
|---|---|
| private T |
| Access | Constructor and Description |
|---|---|
| protected | AbstractSequentialIterator(T firstOrNull)
Creates a new iterator with the given first element, or, if |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract T | computeNext(T previous)
Returns the element that follows |
| public final boolean | |
| public final T |
| nextOrNull | back to summary |
|---|---|
| private T nextOrNull
| |
| AbstractSequentialIterator | back to summary |
|---|---|
| protected AbstractSequentialIterator(T firstOrNull) Creates a new iterator with the given first element, or, if | |
| computeNext | back to summary |
|---|---|
| protected abstract T computeNext(T previous) Returns the element that follows
| |
| hasNext | back to summary |
|---|---|
| public final boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public final T next() Implements java. Doc from java. Returns the next element in the iteration.
| |