// ******************************************************** // Header file QueueP.h for the ADT queue. // Pointer-based implementation. // ******************************************************** using namespace std; #include "QueueException.h" #include "party.h" #include #ifndef QUEUEP_H #define QUEUEP_H typedef party QueueItemType; class Queue { public: // constructors and destructor: Queue(); // default constructor Queue(const Queue& Q) // copy constructor throw(runtime_error); ~Queue(); // destructor // Queue operations: bool isEmpty() const; // Determines whether the queue is empty. // Precondition: None. // Postcondition: Returns true if the queue is empty; // otherwise returns false. void enqueue(QueueItemType newItem) throw (runtime_error); // Inserts an item at the back of a queue. // Precondition: newItem is the item to be inserted. // Postcondition: If the insertion is successful, newItem // is at the back of the queue. // Exception: Throws QueueException if newItem cannot // be placed on the queue. void dequeue() throw (QueueException); // Dequeues the front of a queue. // Precondition: None. // Postcondition: If the queue is not empty, the item // that was added to the queue earliest is deleted. // Exception: Throws QueueException if the queue is // empty. void dequeue(QueueItemType& queueFront) throw (QueueException); // Retrieves and deletes the front of a queue. // Precondition: None. // Postcondition: If the queue is not empty, queueFront // contains the item that was added to the queue // earliest, and the item is deleted. // Exception: Throws QueueException if the queue is // empty. void getFront(QueueItemType& queueFront) const throw (QueueException); // Retrieves the item at the front of a queue. // Precondition: None. // Postcondition: If the queue is not empty, queueFront // contains the item that was added to the queue // earliest. // Exception: Throws QueueException if the queue is // empty. private: // The queue is implemented as a linked list // with one external pointer to the front of the queue // and a second external pointer to the back of the // queue. struct QueueNode { QueueItemType item; QueueNode *next; }; // end struct QueueNode *frontPtr; QueueNode *backPtr; }; // end class #endif