Class ArrayIterator<E>

java.lang.Object
edu.uky.ai.util.ArrayIterator<E>
Type Parameters:
E - the kind of object returned by the iterator
All Implemented Interfaces:
java.util.Iterator<E>

public class ArrayIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>
Iterates through all the elements in an array.
Author:
Stephen G. Ware
  • Constructor Summary

    Constructors 
    Constructor Description
    ArrayIterator​(E[] array)
    Constructs a new array iterator for a given array starting at a given index.
    ArrayIterator​(E[] array, int start)
    Constructs a new array iterator for a given array starting at a given index.
  • Method Summary

    Modifier and Type Method Description
    boolean hasNext()  
    E next()  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Constructor Details

    • ArrayIterator

      public ArrayIterator​(E[] array, int start)
      Constructs a new array iterator for a given array starting at a given index.
      Parameters:
      array - the array to iterate through
      start - the first element to return
    • ArrayIterator

      public ArrayIterator​(E[] array)
      Constructs a new array iterator for a given array starting at a given index. This constructor is equivalent to ArrayIterator(array, 0).
      Parameters:
      array - the array to iterate through
  • Method Details

    • hasNext

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

      public E next()
      Specified by:
      next in interface java.util.Iterator<E>