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>
- Direct Known Subclasses:
Iterators.ArrayItr
abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E>
This class provides a skeletal implementation of theListIteratorinterface 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 protectedAbstractIndexedListIterator(int size)Constructs an iterator across a sequence of the given size whose initial position is 0.protectedAbstractIndexedListIterator(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 Eget(int index)Returns the element with the specified index.booleanhasNext()booleanhasPrevious()Enext()intnextIndex()Eprevious()intpreviousIndex()-
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 throwNoSuchElementExceptionifsizeis zero).- Throws:
java.lang.IllegalArgumentException- ifsizeis 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 precedingpositionelements.- Throws:
java.lang.IndexOutOfBoundsException- ifpositionis negative or is greater thansizejava.lang.IllegalArgumentException- ifsizeis 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()
-
-