CS 132
Computer Science II
Queues


David B. Levine
Computer Science Department
St. Bonaventure University
Copyright,  2000, 2001

Objective

     In this lab you will create a templated queue class that could be used in a more sophisticated application.

A Word of Warning

     Templated classes do not appear in the Source folder for projects.  Therefore, when you create your project, is should include only the .cpp file for the driver - and apstring.cpp if you are testing queues of strings.

 

Instructions:

  1. There are some issues involved with creating a templated class (such as you are required to do for this lab).  Begin by looking at the files stack.h and stack.cpp to see how they differ from the code presented in class.  The primary differences involve commenting and the particular syntax for templates.  Pay attention to both categories of differences.


  2. Begin by writing queue.h.  Using stack.h as a model, this should be relatively simple.  If you do this via the "Save As" method, be sure to remove all references to stacks.


  3. Next implement the functions you declared in queue.cpp.  In the "real world" you would be permitted to choose your own implementation, but in this case we are insisting that you use a linked list of nodes to implement your queue.  Again, stack.cpp may be a good guideline.  As you code, you should be careful to consider the issues related to empty queues.  The text may also contain some code that you find useful.


  4. Of course, one cannot write new code without testing it for correctness.  You are to write a test driver with two parts.  A short test driver for the stack class can be found in the CS132 folder on the server.  The first part of your driver should behave analogously to that one. 

    Then, as the second part of the driver, you are to add code that measures the size of a queue, ultimately leaving the queue in the same state that it was before the measurement began.  If your queue class had a Size function this would be trivial, but that's not the case here.  Rather, you are to determine the size by emptying the queue into another queue and then refilling the original, counting as you go.




To Hand In

 

            Hand in printouts of the three files you create, along with a cover page.

 

Due Date

 

            Due to the fact that we have no lab next week (enjoy the turkey!), this lab is due at noon on Tuesday, November 27.

 

 

Assignment Type (see Academic Practices and Policies Document):

            Group assignment, limited collaboration.