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
-
Method Details
-
hasNext
boolean hasNext()Returnstrue
if the iteration has more elements. (In other words, returnstrue
ifnext()
would return an element rather than throwing an exception.)- Returns:
true
if the iterator has more elements.
-
next
Returns the next element in the iteration.- Returns:
- The next element in the iteration.
- Throws:
NoSuchElementException
- If the iteration has no more elements.
-