|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Objectorg.tbull.util.Collections.LazyGrepIterator<E>
public static class Collections.LazyGrepIterator<E>
An iterator that provides the grepLazy functionality.
The lazy iterator guarantees to fetch only so many elements from the input lists/iterators as are
necessary to compute the result of a call to hasNext() or next(). Also, an input
list/iterator is not queried before the input before it is exhausted.
You can get the lazy iterator by direct instantiation or using one of the grepLazy functions.
RuntimeExceptions from the input iterators are passed along. Notably, the iterators from the
Collections framework throw ConcurrentModificationException
when they detect you didn't synchronize properly.
This iterator implements Iterator and Iterable at the same time. In case you chain
multiple grep/map invocations as in
grepLazy(grepper2, grepLazy(grepper1, lists))
there arises an ambiguity, because the functions come in an overloaded version for each of them
to take as input, so the compiler will not know which version to choose. You can easily resolve the
ambiguity by either invoking the iterator() method on the intermediate IterableIterator
like
grepLazy(grepper2, grepLazy(grepper1, lists).iterator())
or by casting it to a pure Iterator
grepLazy(grepper2, (Iterator) grepLazy(grepper1, lists)).
| Constructor Summary | |
|---|---|
Collections.LazyGrepIterator(Grepper<? super E> grepper,
Iterable<E>[] lists)
Constructs a LazyGrepIterator that iterates over the given iterables (lists). |
|
Collections.LazyGrepIterator(Grepper<? super E> grepper,
Iterator<E>[] iterators)
Constructs a LazyGrepIterator that fetches from the given iterators. |
|
| Method Summary | |
|---|---|
boolean |
hasNext()
|
Iterator<E> |
iterator()
|
E |
next()
|
void |
remove()
Always throws UnsupportedOperationException. |
| Methods inherited from class Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Collections.LazyGrepIterator(Grepper<? super E> grepper,
Iterable<E>[] lists)
public Collections.LazyGrepIterator(Grepper<? super E> grepper,
Iterator<E>[] iterators)
| Method Detail |
|---|
public boolean hasNext()
hasNext in interface Iterator<E>
public E next()
throws NoSuchElementException
next in interface Iterator<E>NoSuchElementException
public void remove()
throws IllegalStateException,
UnsupportedOperationException
UnsupportedOperationException.
remove in interface Iterator<E>IllegalStateException
UnsupportedOperationExceptionpublic Iterator<E> iterator()
iterator in interface Iterable<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||