Class ArrayIterator<T>

  • All Implemented Interfaces:
    java.util.Iterator<T>
    Direct Known Subclasses:
    ArrayNonNullIterator

    public class ArrayIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    an Iterator of array elements
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int _cnt
      The index of the next array element to return
      protected T[] _elts
      The array source for the iterator
      protected int last
      The index of the last array element to return
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      T next()  
      void 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
    • Field Detail

      • _cnt

        protected int _cnt
        The index of the next array element to return
      • last

        protected final int last
        The index of the last array element to return
      • _elts

        protected final T[] _elts
        The array source for the iterator
    • Constructor Detail

      • ArrayIterator

        public ArrayIterator​(T[] elts)
        Parameters:
        elts - the array which should be iterated over
      • ArrayIterator

        public ArrayIterator​(T[] elts,
                             int start)
        Parameters:
        elts - the array which should be iterated over
        start - the first array index to return
      • ArrayIterator

        public ArrayIterator​(T[] elts,
                             int start,
                             int last)
        Parameters:
        elts - the array which should be iterated over
        start - the first array index to return
    • Method Detail

      • hasNext

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

        public T next()
               throws java.util.NoSuchElementException
        Specified by:
        next in interface java.util.Iterator<T>
        Throws:
        java.util.NoSuchElementException
      • remove

        public void remove()
                    throws java.lang.UnsupportedOperationException
        Specified by:
        remove in interface java.util.Iterator<T>
        Throws:
        java.lang.UnsupportedOperationException