L
- the type of the containing listE
- the type of elements returned by this iterator@ParametersAreNonnullByDefault public class LazyIterator<L extends List<E>,E> extends Object implements Iterator<E>
Iterator
that delegates its operations (structural and verification) to the containing list.Modifier and Type | Field and Description |
---|---|
protected L |
containingList
The containing list
|
protected int |
cursor
The current position of the iterator.
|
protected int |
expectedModCount
The modification count of the containing list.
|
protected int |
lastCursor
The previous position of the iterator.
|
protected IntSupplier |
modCount
The function to retrieve the modification count of the containing list.
|
protected LazyInt |
size
The cached size of the containing list.
|
Constructor and Description |
---|
LazyIterator(L containingList,
IntSupplier modCount)
Constructs a new
LazyIterator . |
Modifier and Type | Method and Description |
---|---|
protected void |
checkModCount()
Ensures that the modification count is as expected.
|
protected void |
checkNotReadOnly()
Ensures that this iterator is not read-only before executing a write operation.
|
protected E |
doGet(int index)
Returns the element at the specified
index in the containing list. |
protected void |
doRemove(int index)
Removes the element at the specified
index in the containing list. |
boolean |
hasNext() |
E |
next() |
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
@Nonnull protected final IntSupplier modCount
@Nonnegative protected int cursor
protected int lastCursor
protected int expectedModCount
public LazyIterator(L containingList, IntSupplier modCount)
LazyIterator
.containingList
- the containing listmodCount
- the function to retrieve the modification count of the containing list@Nonnull protected E doGet(int index)
index
in the containing list.index
- index of the element to returnprotected void doRemove(int index)
index
in the containing list.index
- the index of the element to be removedprotected void checkModCount()
ConcurrentModificationException
- if the modification count is not as expected.protected void checkNotReadOnly()
UnsupportedOperationException
- if this iterator is read-onlyCopyright © 2013–2019 Atlanmod. All rights reserved.