Revision 1: 2 October 2012 (corrected the lines with # in column 79) CS 3500 Assignment #5 ! Assigned: Tuesday, 2 October 2012 Due: Tuesday, 9 October 2012 The purposes of this assignment are: * to review Java interfaces * to implement an iterator() method * to prepare for future assignments You will extend the implementation in Java of the FMap ADT that was specified in assignment 4 by implementing the Iterable interface and by adding two public dynamic methods as specified below. Collaboration between students is forbidden on this assignment. You are responsible for keeping your code hidden from all other students. Turn in your work on this assignment before 10 pm on the due date by using the submit script as documented on the course's main assignments web page, http://www.ccs.neu.edu/course/cs3500wc/assignments.html Your file of Java code should begin with a block comment that lists 1. Your name, as you want the instructor to write it. 2. Your email address. 3. Any remarks that you wish to make to the instructor. Part of your grade will depend on the quality and correctness of your code, part will depend on the readability of your code (including comments and indentation), and part will depend on how well you follow the procedure above for submitting your work. Late assignments may be discounted, and very late assignments will be discarded. -------------------------------------------------- Your assignment is to write the code for a single file, FMap.java, that implements the specification below as well as the specification given in assignment 4. A test program (/course/cs3500wc/Assignments/A5/TestFMap.java) will be provided. ! -------------------------------------------------- Specification of the FMap ADT. The FMap ADT remains as specified in assignment 4, ! except that it must now implement Iterable and must now provide the two new client-visible methods specified below. The FMap ADT remains immutable. The FMap class shall provide all of the methods specified in assignment 4. In addition, that class shall provide the ! following public methods: Signature: Dynamic methods (whose receiver is an FMap): iterator: -> Iterator iterator: java.util.Comparator -> Iterator Specification of the iterator() method: Returns an Iterator that generates every key k such that m.containsKey(k) is true, and generates each of those keys exactly once. The next() method of the Iterator returned by m.iterator() must throw a NoSuchElementException if it is called when no more keys remain to be generated, and the remove() method must throw an UnsupportedOperationException every time it is called. Specification of the iterator(Comparator) method: As above, with the additional constraint that the keys are generated in increasing order as determined by the argument passed to the iterator method. --------------------------------------------------