Class ArrayIterable<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>

    public final class ArrayIterable<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>

    Adapter class for using an Array as an Iterable, particularly, for allowing parts of an array to be the iterable. Does not make a copy of the array, so changes to the array will affect the Iterable and Iterators created from it.

    Since:
    2.0
    Version:
    2.0
    Author:
    Michael Grove
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<T> iterator()
      • Methods inherited from class java.lang.Object

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

        forEach, spliterator
    • Constructor Detail

      • ArrayIterable

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

        public ArrayIterable​(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

      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>