Class AbstractFilteredIterator<E>
java.lang.Object
com.globalmentor.collections.iterators.AbstractPrimedIterator<E>
com.globalmentor.collections.iterators.AbstractFilteredIterator<E>
- Type Parameters:
E
- The type of element returned by the iterator.
- All Implemented Interfaces:
Iterator<E>
- Direct Known Subclasses:
FilteredIterator
Abstract implementation of an iterator that filters an existing iterator.
This version does not support AbstractPrimedIterator.remove()
.
This version releases the decorated iterator when iteration is finished.
This class is not thread safe.
- Author:
- Garret Wilson
-
Constructor Summary
ConstructorDescriptionAbstractFilteredIterator
(Iterator<E> iterator) Decorated iterator constructor. -
Method Summary
Methods inherited from class com.globalmentor.collections.iterators.AbstractPrimedIterator
hasNext, next, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
AbstractFilteredIterator
Decorated iterator constructor.- Parameters:
iterator
- The decorated iterator to be filtered.- Throws:
NullPointerException
- if the given iterator isnull
.
-
-
Method Details
-
primeNext
Returns the next available element for the iterator. The value returned by this method will be returned by the next call toAbstractPrimedIterator.next
. The implementation guarantees that this method will not be called again afternull
is returned.- Specified by:
primeNext
in classAbstractPrimedIterator<E>
- Returns:
- The next primed value for the iterator, or
null
if there are no further values. - See Also:
-
isPass
Indicates whether the given element is included when filtering.- Parameters:
element
- The element in the filtered iterator.- Returns:
true
if the element should be included, ornull
if it should be filtered out.
-