public class SkippingIterator<E> extends AbstractIteratorDecorator<E>
In case an offset parameter other than 0 is provided, the decorated iterator is immediately advanced to this position, skipping all elements before that position.
| Constructor and Description |
|---|
SkippingIterator(Iterator
Decorates the specified iterator to skip all elements until the iterator reaches the position at
offset.
|
| Modifier and Type | Method and Description |
|---|---|
E |
next()
|
void |
remove()
|
getIterator, hasNextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic SkippingIterator(Iterator<E> iterator, long offset)
offset.
The iterator is immediately advanced until it reaches the position at offset, incurring O(n) time.
iterator - the iterator to be decorated
offset - the index of the first element of the decorated iterator to return
NullPointerException - if iterator is null
IllegalArgumentException - if offset is negative
public E next()
AbstractIteratorDecorator
public void remove()
In case an offset other than 0 was specified, the underlying iterator will be advanced to this position upon creation. A call to remove() will still result in an IllegalStateException if no explicit call to next() has been made prior to calling remove().