Iteration Abstraction, and a bit of Type Abstraction.
The point of this exercise is to show some
of the power of interfaces in Java.
In particular, the
interface allows for the writing of extremely
safe and compact for loops.
Build a new version of
that implements the Java
should be consistent with how iterators on lists normally behave.
(But see below for a specific detail that you need to consider.)
Provide a reasonable set of JUnit tests for your implementation.
Notes: Implement the iterator with a private inner class. See Liskov's
For this exercise, don't build on top of the iterators
available through the
Map interface, even
though doing so is typically preferable.
Make sure you deal with the
remove() method appropriately.
That is, analyze valid
and then conclude how
remove() must behave.
I expect to see a robust discussion of this point on Piazza.
I'm going to refrain from jumping in until we see if the class
can work out the correct answer without my input.
If you get stuck on the generics, do the exercise with the generic parameter
E bound to
You won't get full credit, but you'll earn most of the credit,
and you won't get hung up focused on something that's not the
point of the exercise.