Top Description Fields Constructors Methods
com.google.common.collect

pack-priv abstract Class AbstractIndexedListIterator<E extends @Nullable Object>

extends UnmodifiableListIterator<E extends @Nullable Object>
Class Inheritance
Known Direct Subclasses
com.google.common.collect.Iterators.ArrayItr
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkPositionIndex

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 remove, set, or add.
Author
Jared Levy

Field Summary

Modifier and TypeField and Description
private int
private final int

Constructor Summary

AccessConstructor and 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

Modifier and TypeMethod and Description
protected abstract E
get(int index)

Returns the element with the specified index.

public final boolean
hasNext()

Implements java.util.ListIterator.hasNext, java.util.Iterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction.
public final boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.
public final E
next()

Implements java.util.ListIterator.next, java.util.Iterator.next.

Returns the next element in the list and advances the cursor position.
public final int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public final E
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.
public final int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
Inherited from com.google.common.collect.UnmodifiableListIterator:
addset

Field Detail

positionback to summary
private int position
sizeback to summary
private final int size

Constructor Detail

AbstractIndexedListIteratorback to summary
protected AbstractIndexedListIterator(int size)

Constructs an iterator across a sequence of the given size whose initial position is 0. That is, the first call to next() will return the first element (or throw NoSuchElementException if size is zero).

Exceptions
IllegalArgumentException:
if size is negative
AbstractIndexedListIteratorback to summary
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 to nextIndex() will return position, and the first call to next() will return the element at that index, if available. Calls to previous() can retrieve the preceding position elements.

Exceptions
IndexOutOfBoundsException:
if position is negative or is greater than size
IllegalArgumentException:
if size is negative

Method Detail

getback to summary
protected abstract E get(int index)

Returns the element with the specified index. This method is called by next().

Annotations
@ParametricNullness
hasNextback to summary
public final boolean hasNext()

Implements java.util.ListIterator.hasNext, java.util.Iterator.hasNext.

Doc from java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the forward direction

Annotations
@Override
hasPreviousback to summary
public final boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the reverse direction

Annotations
@Override
nextback to summary
public final E next()

Implements java.util.ListIterator.next, java.util.Iterator.next.

Doc from java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the next element in the list

Annotations
@Override
@ParametricNullness
nextIndexback to summary
public final int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list

Annotations
@Override
previousback to summary
public final E previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the previous element in the list

Annotations
@Override
@ParametricNullness
previousIndexback to summary
public final int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list

Annotations
@Override