CS 231: Lab #7

We're going to work through how to write a queue in lab. The queue should implement the functions listed under the Queue interface in the java documentation. We won't worry about the more general Collection interface functions.

Documentation for Java 1.5 is located at: Java 1.5 SE API.

Documentation for Java 1.6 is located at: Java 1.6 SE API


  1. Find the Queue interface documentation and see what the key functions are.
  2. Implement the queue as a singly-linked list.
  3. Implement an iterator for the queue so it can implement the Iterable interface.
  4. Implement a method public int position(Object obj) that returns the position of the given Object in the queue.

For more details, see this week's assignment.