The decorated iterator is bounded in the range [offset, offset+max).
The offset corresponds to the position of the first element to
be returned from the decorated iterator, and max is the maximum
number of elements to be returned at most.
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.
| Modifier and Type | Field and Description |
|---|---|
| private final Iterator | iterator
The iterator being decorated. |
| private final long | max
The max number of elements to return |
| private final long | offset
The offset to bound the first element return |
| private long | pos
The position of the current element |
| Access | Constructor and Description |
|---|---|
| public | BoundedIterator(final Iterator<? extends E>
the iterator to be decorated iterator, final long the index of the first element of the decorated iterator to return offset, final long the maximum number of elements of the decorated iterator to return max)Decorates the specified iterator to return at most the given number of elements,
skipping all elements until the iterator reaches the position at |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | Returns: true if the iterator is within its bounds, false otherwiseChecks whether the iterator is still within its bounded range. |
| public boolean | |
| private void | |
| public E | |
| public void | remove()
Overrides default java. |
| iterator | back to summary |
|---|---|
| private final Iterator<? extends E> iterator The iterator being decorated. | |
| max | back to summary |
|---|---|
| private final long max The max number of elements to return | |
| offset | back to summary |
|---|---|
| private final long offset The offset to bound the first element return | |
| pos | back to summary |
|---|---|
| private long pos The position of the current element | |
| BoundedIterator | back to summary |
|---|---|
| public BoundedIterator(final Iterator<? extends E> iterator, final long offset, final long max) Decorates the specified iterator to return at most the given number of elements,
skipping all elements until the iterator reaches the position at
The iterator is immediately advanced until it reaches the position at
| |
| checkBounds | back to summary |
|---|---|
| private boolean checkBounds() Checks whether the iterator is still within its bounded range.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| init | back to summary |
|---|---|
| private void init() Advances the underlying iterator to the beginning of the bounded range. | |
| next | back to summary |
|---|---|
| public E next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
In case an offset other than 0 was specified, the underlying iterator will be advanced
to this position upon creation. A call to
| |