CMPS 144L Intersession 2020
Lab #6: QueueViaLink1 using only a Rear Pointer

In the web page describing queues (see link on course web page), you can see the source code of QueueViaLink1, which is an implementation of the Queue interface. This implementation uses a linked chain of Link1 objects "containing" the items occupying the queue. To provide access to the Link1 objects at opposite ends of that chain, the class has two instance variables, front and rear.

Immediately below the source code of QueueViaLink1 on that web page is described a slightly different implementation technique in which the Link1 objects holding the queue items are linked together in a cycle, with the Link1 object "at the the rear" using its next instance variable to point to the Link1 object "at the front", thus making the front instance variable superfluous. (To obtain a reference to the front, just use rear.next.)

Modify the given QueueViaLink1 class so that it is based upon this different technique. Call the new class QueueViaLink1B (for lack of a better name). Except for toString(), no method in the class should have a loop.

The QVL1B_TestApp can be used for testing purposes. It performs the same sequence of operations upon both an instance of QueueViaLink1 and an instance of QueueViaLink1B, and it prints a message whenever it finds the two queues not to be in agreement with each other.