public class IlvSelectiveIterator<E> extends Object implements Iterator<E>
IlvSelectiveIterator wrappers an existing Iterator so that it
will only visit elements in the original iteration that match a certain criteria. This
criteria is defined by an IlvUnaryPredicate which is evaluated against
every element. Those elements in the original iteration which cause the predicate to
evaluate false are skipped.| Constructor and Description |
|---|
IlvSelectiveIterator(Iterator<? extends E> iterator,
IlvUnaryPredicate<? super E> predicate)
Constructs an
IlvSelectiveIterator that will selectively traverse the
elements from the specified iterator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Returns whether the iteration has more elements.
|
E |
next()
Returns the next element in the iteration.
|
void |
remove()
Removes from the underlying collection the last object returned by the iterator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic IlvSelectiveIterator(Iterator<? extends E> iterator, IlvUnaryPredicate<? super E> predicate)
IlvSelectiveIterator that will selectively traverse the
elements from the specified iterator. The unary predicate
is applied to each element in the original iteration to select which elements will be
traversed by the new IlvSelectiveIterator.iterator - The original iterator.predicate - The unary predicate that is applied to each of iterator
elements. Those that evaluate true are returned by this
iterator.public boolean hasNext()
true if next() would return an element rather than throwing
an exception.)public E next()
next in interface Iterator<E>NoSuchElementException - if the iteration has no more elements.public void remove()
next.
The method is optional and currently throws an unconditional
UnsupportedOperationException.
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.