T
- Type of IteratorS
- Type of objects returned by the iterator.public abstract class FilterIterator<T,S> extends Object implements Iterator<S>
Constructor and Description |
---|
FilterIterator(Iterator<T> i)
Create a new iterator based on an old one.
|
Modifier and Type | Method and Description |
---|---|
protected abstract S |
filter(T o)
Returns the object corresponding to the given object, or null if that object is to be skipped.
|
boolean |
hasNext()
Returns true if the iteration has more elements.
|
S |
next()
Returns the next element in the iteration.
|
void |
remove()
Removes from the underlying collection the last element returned by the iterator (optional operation).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public FilterIterator(Iterator<T> i)
i
- An iteratorprotected abstract S filter(T o)
o
- An object in the source iterator domainpublic boolean hasNext()
public S next()
hasNext()
method
returns false will return each element in the underlying collection exactly once.next
in interface Iterator<S>
NoSuchElementException
- iteration has no more elements.public void remove()
remove
in interface Iterator<S>
UnsupportedOperationException
- if the remove operation is not supported by this Iterator.IllegalStateException
- if the next method has not yet been called, or the remove method
has already been called after the last call to the next method.Copyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.