Class ObjectArrayListIterator<E>

java.lang.Object
org.apache.commons.collections4.iterators.ObjectArrayIterator<E>
org.apache.commons.collections4.iterators.ObjectArrayListIterator<E>
Type Parameters:
E - The type of elements returned by this iterator.
All Implemented Interfaces:
Iterator<E>, ListIterator<E>, OrderedIterator<E>, ResettableIterator<E>, ResettableListIterator<E>

public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E> implements ResettableListIterator<E>
Implements a ListIterator over an array of objects.

This iterator does not support add(E) or ObjectArrayIterator.remove(), as the object array cannot be structurally modified. The set(E) method is supported however.

The iterator implements a reset() method, allowing the reset of the iterator back to the start if required.

Since:
3.0
See Also:
  • Field Details

    • lastItemIndex

      private int lastItemIndex
      Holds the index of the last item returned by a call to next() or previous(). This is set to -1 if neither method has yet been invoked. lastItemIndex is used to implement the set(E) method.
  • Constructor Details

    • ObjectArrayListIterator

      public ObjectArrayListIterator(E... array)
      Constructs an ObjectArrayListIterator that will iterate over the values in the specified array.
      Parameters:
      array - The array to iterate over
      Throws:
      NullPointerException - if array is null
    • ObjectArrayListIterator

      public ObjectArrayListIterator(E[] array, int start)
      Constructs an ObjectArrayListIterator that will iterate over the values in the specified array from a specific start index.
      Parameters:
      array - The array to iterate over
      start - The index to start iterating at
      Throws:
      NullPointerException - if array is null
      IndexOutOfBoundsException - if the start index is out of bounds
    • ObjectArrayListIterator

      public ObjectArrayListIterator(E[] array, int start, int end)
      Constructs an ObjectArrayListIterator that will iterate over a range of values in the specified array.
      Parameters:
      array - The array to iterate over
      start - The index to start iterating at
      end - The index (exclusive) to finish iterating at
      Throws:
      IndexOutOfBoundsException - if the start or end index is out of bounds
      IllegalArgumentException - if end index is before the start
      NullPointerException - if array is null
  • Method Details