/***************************************************************************************** File objq.cpp Description Provides a definition of a class implementing a queue using the underlying data structure of a List. The derivation is 'private' because class Queue inherents the implementation, but not the interface of class List. Public Methods Queue::remove void Queue::insert ItemType i *****************************************************************************************/ #include #include "objq.h" /***************************************************************************************** Function Queue::remove Parameters None Returns Returns the item removed from the head of the queue. Description Remove the item at the head of the queue. Change History 06/19/98 (thh) Initial Definition based on modifications to code provided with Instructor's Manual to accompany Programming Languages Paradigm and Practice, 2nd Edition by Doris Appleby and Julius J. VandeKopple, McGraw Hill, 1997. *****************************************************************************************/ ItemType Queue::remove() { if (len <= 0) { cerr << "Attempt to remove an item from an empty queue" << endl; return 0; } --len; return List::RemoveFromFront(); } /***************************************************************************************** Function Queue::insert Parameters i (I) ItemType Returns None Description Insert an item at the tail of the queue. Change History 06/19/98 (thh) Initial Definition based on modifications to code provided with Instructor's Manual to accompany Programming Languages Paradigm and Practice, 2nd Edition by Doris Appleby and Julius J. VandeKopple, McGraw Hill, 1997. *****************************************************************************************/ void Queue::insert(ItemType i) { List::AddToEnd(i); ++len; }