|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectDeferringIterator<E>
E - The type of elements to be returned by the iterator.@Decorator(value=java.util.Iterator.class) public abstract class DeferringIterator<E>
An iterator deferring to the iteration end any object which comply to some criterion. This class needs:
isDeferred(T) method.
When the next() method is invoked, DeferringIterator first delegates to
the next() method of the wrapped iterator, then gives the obtained element to the
isDeferred method. If isDeferred returns true,
then the element is returned immediately. Otherwise the element is enqueued and will be
returned in queue insertion order only after all non-deferred elements have been returned
by this iterator.
| utility/geotk-utility (download) | View source code for this class |
| Constructor Summary | |
|---|---|
protected |
DeferringIterator(Iterator<E> iterator)
Creates a new deferring iterator. |
| Method Summary | |
|---|---|
boolean |
hasNext()
Returns true if the iteration has more elements. |
protected abstract boolean |
isDeferred(E element)
Returns true if the given element should be deferred at the end of the iteration. |
E |
next()
Returns the next element in the iteration. |
void |
remove()
Removes the last element returned by the iterator. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected DeferringIterator(Iterator<E> iterator)
iterator - The iterator to wrap.| Method Detail |
|---|
protected abstract boolean isDeferred(E element)
true if the given element should be deferred at the end of the iteration.
This method is invoked by the next() method for all objects returned by the
wrapped iterator. If this method returns true, then the given element will be
returned immediately by the next() method. Otherwise the element is enqueued
and will be returned only after all non-deferred elements have been returned.
element - The object to test. May be null if the wrapped iterator can
returns null elements.
true if the given object should be deferred at the end of the iteration.public boolean hasNext()
true if the iteration has more elements.
hasNext in interface Iterator<E>public E next()
next in interface Iterator<E>
public void remove()
throws UnsupportedOperationException
remove in interface Iterator<E>UnsupportedOperationException - If the iterator is iterating over deferred elements,
or if the wrapped iterator does not support this operation.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||