Class ArrayIterator<T>

  • Type Parameters:
    T - the type of elements that will be iterated over
    All Implemented Interfaces:
    com.google.common.collect.PeekingIterator<T>, java.util.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 Summary

      Constructors 
      Constructor Description
      ArrayIterator​(T[] theArray)
      Create a new ArrayIterator
      ArrayIterator​(T[] theArray, int theStart, int theEnd)
      Create a new ArrayIterator
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> ArrayIterator<T> create​(T... theElements)  
      boolean hasNext()
      T next()
      T peek()
      • Methods inherited from class com.google.common.collect.UnmodifiableIterator

        remove
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
      • Methods inherited from interface com.google.common.collect.PeekingIterator

        remove
    • Constructor Detail

      • 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 Detail

      • create

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

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

        public T next()
        Specified by:
        next in interface java.util.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>