CS 231: Lab #6

Queues

We're going to work through the methods that define a queue in lab. The queue should implement the functions listed under the Queue interface in the java documentation, but it does not need to implement the Queue interface. It should implement the Iterable interface.

We're not implementing the Queue interface because for this project we're ignoring the larger set of Collection methods required by the Queue interface.

You can use your existing linked list implementation (single or double) to implement the Queue interface.

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


Tasks

  1. Find the Queue interface documentation and see what the key functions are. What is the difference between them?
  2. Implement the six interface functions. The add and offer methods should put the new node on the end of the queue, and the remove and poll methods should remove and return the data in the node at the head of the queue.
  3. Make sure your iterator loops over the linked list from the head to the tail of the queue.

For more details, see this week's assignment.