Package eu.bandm.tools.util.java
Class Iterators.FilterIterator<A>
java.lang.Object
eu.bandm.tools.util.java.Iterators.FilterIterator<A>
- Type Parameters:
A- the element type
- All Implemented Interfaces:
Iterator<A>
- Enclosing class:
Iterators
An iterator that passes on only selected elements.
Which elements are passed on from the underlying iterator and which are suppressed may depend on the elements themselves, as well as on the state of the filter.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFilterIterator(Iterator<? extends A> i) Creates a new instance. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
FilterIterator
Creates a new instance.- Parameters:
i- the underlying iterator
-
-
Method Details
-
accepts
Checks whether an element should be passed on or suppressed.This method is called exactly once for each element. It may both use and modify internal state.
- Parameters:
candidate- the candidate element- Returns:
trueif the element is to be passed on;falseif it is to be suppressed
-
hasNext
public boolean hasNext()Checks whether there is a next element. -
next
Returns the next element and advances the iterator.- Specified by:
nextin interfaceIterator<A>- Returns:
- the next element
- Throws:
NoSuchElementException- if there are no more elements
-
remove
public void remove()Removes the previously returned element.
-