📄 c07p346.txt
字号:
// ********************************************************// Header file QueueP.h for the ADT queue.// Pointer-based implementation.// ********************************************************#include "QueueException.h"typedef desired-type-of-queue-item QueueItemType;class Queue{public:// constructors and destructor: Queue(); // default constructor Queue(const Queue& Q); // copy constructor ~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); // 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. 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 *backPtr; QueueNode *frontPtr;}; // end class// End of header file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -