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:
java.util.Iterator<E>
,java.util.ListIterator<E>
@GwtCompatible abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E>
This class provides a skeletal implementation of theListIterator
interface across a fixed number of elements that may be retrieved by position. It does not supportUnmodifiableIterator.remove()
,UnmodifiableListIterator.set(E)
, orUnmodifiableListIterator.add(E)
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract E
get(int index)
Returns the element with the specified index.boolean
hasNext()
boolean
hasPrevious()
E
next()
int
nextIndex()
E
previous()
int
previousIndex()
-
Methods inherited from class com.google.common.collect.UnmodifiableListIterator
add, set
-
Methods inherited from class com.google.common.collect.UnmodifiableIterator
remove
-
-
-
-
Constructor Detail
-
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:
java.lang.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:
java.lang.IndexOutOfBoundsException
- ifposition
is negative or is greater thansize
java.lang.IllegalArgumentException
- ifsize
is negative
-
-
Method Detail
-
get
protected abstract E get(int index)
Returns the element with the specified index. This method is called bynext()
.
-
hasNext
public final boolean hasNext()
-
next
public final E next()
-
nextIndex
public final int nextIndex()
-
hasPrevious
public final boolean hasPrevious()
-
previous
public final E previous()
-
previousIndex
public final int previousIndex()
-
-