SWE 619 Assignment 5
Spring 2013


Goal: Iteration Abstraction, Immutability, JUnit.

Provide in immutable version, ImmutableIterator, of Liskov's version of the Iterator interface. You need only consider the next() and hasNext() methods. Note that hasNext() is fine as it is, but that you will need to split the next() method into two new methods:

   public Object              nextObject() throws NoSuchElementException
   public ImmutableIterator nextIterator() throws NoSuchElementException

Provide a sample implementation of this interface on Liskov's IntSet class. That is, add the following method to the IntSet API:

   // Effects:  Returns an immutable generator that will produce all of the elements
   // of this, (as Integer), each exactly once, in sorted order, increasing in size.
   // Requires:  this must not be modified while the generator is in use
   public ImmutableIterator iIterator() {...}

Provide appropriate JUnit tests to test the iterator.