Package com.google.common.collect
Class AbstractIndexedListIterator<E>
java.lang.Object
com.google.common.collect.UnmodifiableIterator<E>
com.google.common.collect.UnmodifiableListIterator<E>
com.google.common.collect.AbstractIndexedListIterator<E>
- All Implemented Interfaces:
Iterator<E>
,ListIterator<E>
- Direct Known Subclasses:
Iterators.ArrayItr
This class provides a skeletal implementation of the
ListIterator
interface across a
fixed number of elements that may be retrieved by position. It does not support UnmodifiableIterator.remove()
,
UnmodifiableListIterator.set(E)
, or UnmodifiableListIterator.add(E)
.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractIndexedListIterator
(int size) Constructs an iterator across a sequence of the given size whose initial position is 0.protected
AbstractIndexedListIterator
(int size, int position) Constructs an iterator across a sequence of the given size with the given initial position. -
Method Summary
Methods inherited from class com.google.common.collect.UnmodifiableListIterator
add, set
Methods inherited from class com.google.common.collect.UnmodifiableIterator
remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
Methods inherited from interface java.util.ListIterator
remove
-
Field Details
-
size
private final int size -
position
private int position
-
-
Constructor Details
-
AbstractIndexedListIterator
protected AbstractIndexedListIterator(int size) Constructs an iterator across a sequence of the given size whose initial position is 0. That is, the first call tonext()
will return the first element (or throwNoSuchElementException
ifsize
is zero).- Throws:
IllegalArgumentException
- ifsize
is negative
-
AbstractIndexedListIterator
protected AbstractIndexedListIterator(int size, int position) Constructs an iterator across a sequence of the given size with the given initial position. That is, the first call tonextIndex()
will returnposition
, and the first call tonext()
will return the element at that index, if available. Calls toprevious()
can retrieve the precedingposition
elements.- Throws:
IndexOutOfBoundsException
- ifposition
is negative or is greater thansize
IllegalArgumentException
- ifsize
is negative
-
-
Method Details
-
get
Returns the element with the specified index. This method is called bynext()
. -
hasNext
public final boolean hasNext() -
next
-
nextIndex
public final int nextIndex() -
hasPrevious
public final boolean hasPrevious() -
previous
-
previousIndex
public final int previousIndex()
-