Package utilities

Interface Iterator<E>

Type Parameters:
E - The type of element this iterator returns.
All Known Implementing Classes:
MyArrayList.MyIterator

public interface Iterator<E>
This interface will provide an mono-directional iterator for any of the data structures that are specified in this package. The implementor is only responsible for the simple methods. A more functional iterator is available in the java.util package.

This iterator makes a copy of the collection of elements and performs a complete walk through the data structure. Note that the copy must be a deep copy, so methods such as clone() should not be used.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the iteration has more elements.
    Returns the next element in the iteration.
  • Method Details

    • hasNext

      boolean hasNext()
      Returns true if the iteration has more elements. (In other words, returns true if next() would return an element rather than throwing an exception.)
      Returns:
      true if the iterator has more elements.
    • next

      E next() throws NoSuchElementException
      Returns the next element in the iteration.
      Returns:
      The next element in the iteration.
      Throws:
      NoSuchElementException - If the iteration has no more elements.