// Chap 7, pp 312 - 313 // Rename this file as QueueP.h // ******************************************************** // Header file QueueP.h for the ADT queue. // Pointer-based implementation. // ******************************************************** #ifndef QTYPE typedef int queueItemType; // desired-type-of-queue-item #define QTYPE #endif struct queueNode; // defined in implementation file typedef queueNode* ptrType; // pointer to node #include "boolean.h" class queueClass { public: // constructors and destructor: queueClass(); // constructor queueClass(const queueClass& Q); // copy constructor ~queueClass(); // destructor // queue operations: boolean QueueIsEmpty(); // Determines whether a queue is empty. // Precondition: The constructor has been called. // Postcondition: Returns TRUE if the queue was empty, // otherwise returns FALSE. void QueueAdd(queueItemType NewItem, boolean& Success); // Adds an item to the rear of a queue. // Precondition: NewItem is the item to be added. The // constructor has been called. // Postcondition: If insertion was successful, NewItem // is at the rear of the queue and Success is TRUE; // otherwise Success is FALSE. void QueueRemove(boolean& Success); // Removes the item at the front of a queue. // Precondition: The constructor has been called. // Postcondition: If the queue was not empty, the item // that was added to the queue earliest is removed and // Success is TRUE. However, if the queue was empty, // removal is impossible and Success is FALSE. void GetQueueFront(queueItemType& QueueFront, boolean& Success); // Retrieves the item at the front of a queue. // Precondition: The constructor has been called. // Postcondition: If the queue was not empty, QueueFront // contains the item that was added to the queue earliest // and Success is TRUE. However, if the queue was empty, // the operation fails, QueueFront is unchanged, and // Success is FALSE. The queue is unchanged. private: ptrType Rear; }; // end class // End of header file.