Class ArrayIterator<T>

java.lang.Object
com.google.common.collect.UnmodifiableIterator<T>
com.complexible.common.collect.ArrayIterator<T>
Type Parameters:
T - the type of elements that will be iterated over
All Implemented Interfaces:
com.google.common.collect.PeekingIterator<T>, Iterator<T>

public final class ArrayIterator<T> extends com.google.common.collect.UnmodifiableIterator<T> implements com.google.common.collect.PeekingIterator<T>

Class which adapts an array of objects to the Iterator interface, particularly to allow sub-arrays to be iterated over.

Since:
2.0
Version:
5.0
Author:
Michael Grove
  • Constructor Details

    • ArrayIterator

      public ArrayIterator(T[] theArray)
      Create a new ArrayIterator
      Parameters:
      theArray - the array to iterate over
    • ArrayIterator

      public ArrayIterator(T[] theArray, int theStart, int theEnd)
      Create a new ArrayIterator
      Parameters:
      theArray - the array to iterate over
      theStart - the starting position of the array
      theEnd - the end position of the array
  • Method Details

    • create

      @SafeVarargs public static <T> ArrayIterator<T> create(T... theElements)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next()
      Specified by:
      next in interface Iterator<T>
      Specified by:
      next in interface com.google.common.collect.PeekingIterator<T>
    • peek

      public T peek()
      Specified by:
      peek in interface com.google.common.collect.PeekingIterator<T>