E - the type of elements returned by this iterator.public interface SizedIterator<E> extends Iterator<E>
Iterator that provides the number of remaining elements. This interface can
be used when the number of elements returned in an iteration has to be known
in advance, but the Collection interface cannot be used (e.g. because
elements are consumed by the iterator).
Like regular iterators, sized iterators have to be expected to not be thread-safe unless explicitly stated differently in the documentation of the implementation.
| Modifier and Type | Method and Description |
|---|---|
int |
remainingCount()
Returns the number of elements that will be provided by this iterator.
|
forEachRemaining, hasNext, next, removeint remainingCount()
Returns the number of elements that will be provided by this iterator. If
remainingCount() returns zero, Iterator.hasNext() returns
false. If hasNext() returns true,
remainingCount() returns a number greater than zero. Each
time Iterator.next() is called, this number is decremented by one.
If the number of remaining elements is greater than
Integer.MAX_VALUE, Integer.MAX_VALUE is returned instead
of the actual number.
next can be called without throwing a
NoSuchElementException.Copyright © 2011–2017 aquenos GmbH. All rights reserved.