???
1 Queue
9.3

For this lab you will explore the implementation and use of the queue.

All classes must come with the standard constructor that accepts values for all fields, and all classes must have an ‘equals‘ method that performs a test of value equality on all fields. (Without these, writing precise test cases is more or less impossible.)

As before, follow the design recipe (data definitions if necessary, signature, purpose statement, header, test cases, template when appropriate, fill in body) to design all methods required by this lab.

1 Queue🔗

You must provide two implementations of the Queue data structure. One of the implementations must be implemented as a circular buffer, as discussed below. The other should use a pair of linked lists, one representing the front of the queue, and the other the reversed tail of the queue, as discussed in class.

Both of your queue implementations should implement a "MyQueue" interface that contains all of the methods specified below.

Your queue implementations should be able to handle millions of elements. This will require reversing your linked list using a loop, rather that with recursion; Java is not very good at recursion.

Each Queue implementation must define each of the following functions.

Write your circular buffer implementation in a file named AQueue.java. Write your list-based implementation in a file called LLQueue.java.

  • empty_queue — a static method that returns an empty queue. To simplify the circular queue, we do not require resizing of an array-based queue. This mens that this method should accept a single argument for an array-based queue, indicating the (fixed) size of the queue. For the linked-list-based queue, no argument should be accepted.

  • enqueue — a void method that accepts a string and adds it to the end of the queue.

  • dequeue — a method that removes and returns the element at the front of the queue.If there is no such element, raises an IndexError exception.

  • peek — a method that returns the element at the front of the queue, without removing it. If there is no such element,raises an IndexError exception.

  • size — a method that returns a count of the number of elements currently in the queue.

  • is_empty — a method that returns true when the queue contains no elements.