saker.build Documentation TaskDoc JavaDoc Packages
public class ArrayIterator<Timplements ListIterator<T>
A ListIterator implementation backed by an array.

The iterator is unmodifiable.

The modification of the backing array will not cause this iterator to throw ConcurrentModificationException.

TThe element type.
Constructors
public
ArrayIterator(T[] values)
Creates a new iterator with the parameter array.
public
ArrayIterator(T[] values, int start, int end)
Creates a new iterator with the parameter array and specified range.
public
ArrayIterator(T[] values, int start, int end, int index)
Creates a new iterator with the parameter array, specified range, and initial index.
Methods
public void
add(T e)
Inserts the specified element into the list (optional operation).
public void
forEachRemaining(Consumer<super T> action)
Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
public boolean
Returns true if this list iterator has more elements when traversing the list in the forward direction.
public boolean
Returns true if this list iterator has more elements when traversing the list in the reverse direction.
public T
Returns the next element in the list and advances the cursor position.
public int
Returns the index of the element that would be returned by a subsequent call to next().
public T
Returns the previous element in the list and moves the cursor position backwards.
public int
Returns the index of the element that would be returned by a subsequent call to previous().
public void
Removes from the list the last element that was returned by next() or previous() (optional operation).
public void
set(T e)
Replaces the last element returned by next() or previous() with the specified element (optional operation).
public ArrayIterator(T[] values) throws NullPointerException
Creates a new iterator with the parameter array. The iterator range is the full array.
valuesThe backing array.
NullPointerExceptionIf the array is null.
public ArrayIterator(T[] values, int start, int end) throws IndexOutOfBoundsException, NullPointerException
Creates a new iterator with the parameter array and specified range.
valuesThe backing array.
startThe range start index (inclusive).
endThe range end index (exclusive).
IndexOutOfBoundsExceptionIf the range is not in the argument array.
NullPointerExceptionIf the array is null.
public ArrayIterator(T[] values, int start, int end, int index) throws IndexOutOfBoundsException, NullPointerException
Creates a new iterator with the parameter array, specified range, and initial index. The first call to next() will return the element at the specified index.
valuesThe backing array.
startThe range start index (inclusive).
endThe range end index (exclusive).
indexThe initial index.
IndexOutOfBoundsExceptionIf the range or index is not in the argument array.
NullPointerExceptionIf the array is null.
public void add(T e)
Overridden from: ListIterator
Inserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned by ListIterator.next(), if any, and after the element that would be returned by ListIterator.previous(), if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)
ethe element to insert
public void forEachRemaining(Consumer<super T> action)
Overridden from: Iterator
Performs the given action for each remaining element until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.
actionThe action to be performed for each element
1.8
public boolean hasNext()
Overridden from: ListIterator
Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if ListIterator.next() would return an element rather than throwing an exception.)
true if the list iterator has more elements when traversing the list in the forward direction
public boolean hasPrevious()
Overridden from: ListIterator
Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if ListIterator.previous() would return an element rather than throwing an exception.)
true if the list iterator has more elements when traversing the list in the reverse direction
public T next()
Overridden from: ListIterator
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 ListIterator.previous() to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)
the next element in the list
public int nextIndex()
Overridden from: ListIterator
Returns the index of the element that would be returned by a subsequent call to ListIterator.next(). (Returns list size if the list iterator is at the end of the list.)
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
public T previous()
Overridden from: ListIterator
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 ListIterator.next() to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)
the previous element in the list
public int previousIndex()
Overridden from: ListIterator
Returns the index of the element that would be returned by a subsequent call to ListIterator.previous(). (Returns -1 if the list iterator is at the beginning of the list.)
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
public void remove()
Overridden from: ListIterator
Removes from the list the last element that was returned by ListIterator.next() or ListIterator.previous() (optional operation). This call can only be made once per call to next or previous. It can be made only if ListIterator.add(E) has not been called after the last call to next or previous.
public void set(T e)
Overridden from: ListIterator
Replaces the last element returned by ListIterator.next() or ListIterator.previous() with the specified element (optional operation). This call can be made only if neither ListIterator.remove() nor ListIterator.add(E) have been called after the last call to next or previous.
ethe element with which to replace the last element returned by next or previous