SWE 619 In Class Exercise Number 4A
Consider the Java Iterator<E> interface:
public boolean hasNext();
public E next() throws NoSuchElementException
public void remove() throws IllegalStateException
-
What is the abstract state of an iterator without the
remove()
method?
-
Work through an example iterating over a list of strings: ["bat", "cat", "dog"]
-
What is the abstract state of an iterator with a
previous()
method?
-
What is the abstract state of an iterator with the
remove()
method?
-
Design an immutable version of the iterator.
-
How is
hasNext()
handled?
-
How is
next()
handled?
-
How is
remove()
handled?
-
Exercise the immutable iterator with some sample client code.