E- the type of objects returned by the iterator
Iterators.Filterfilters the stream of objects returned by another iterator by subjecting them to an acceptance test. Instances are constructed with a specified iterator to be filtered; this filter is saved in this class and should not be accessed by other methods. Concrete subclasses must implement
accept(Object), which determines which of the elements produced by the containediterator are returned.
|Constructor and Description|
Construct a filtered iterator from the specified iterator.
|Modifier and Type||Method and Description|
Returns the next value from the contained iterator that is accepted.
This operation is not supported.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public abstract boolean accept(E x)
truefor objects returned by the contained iterator that should be returned by this iterator.
x- Object to test.
trueif this object should be returned by this iterator.
public boolean hasNext()
trueif calls to
next()will return a value.
Implementation note: This iterator stores the next
element in a local variable after calls to this method. Calls to
next() remove this reference.
public E next()
public void remove()
Implementation Note: Because calls to
hasNext() must iterate over the contained iterator to find
the next acceptable object to return, it is not guaranteed that
the last element returned by this iterator is the same as the
last element returned by the underlying iterator. Thus the
underlying iterator can't be used to do the removal without
tripping the fail-fast behavior of