class LinkedQueue
1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
4: /** ADT queue: Link-based implementation.
5: Listing 14-3.
6: @file LinkedQueue.h */
7: #ifndef _LINKED_QUEUE
8: #define _LINKED_QUEUE
10: #include "QueueInterface.h"
11: #include "Node.h"
12: #include "PrecondViolatedExcep.h"
14: template<class ItemType>
15: class LinkedQueue : public QueueInterface<ItemType>
16: {
17: private:
18: // The queue is implemented as a chain of linked nodes that has
19: // two external pointers, a head pointer for front of the queue and
20: // a tail pointer for the back of the queue.
21: Node<ItemType>* backPtr;
22: Node<ItemType>* frontPtr;
24: public:
25: LinkedQueue();
26: LinkedQueue (const LinkedQueue& aQueue);
27: ~LinkedQueue();
29: bool isEmpty() const;
30: bool enqueue(const ItemType& newEntry);
31: bool dequeue();
32:
33: /** @throw PrecondViolatedExcep if the queue is empty */
34: ItemType peekFront() const throw(PrecondViolatedExcep);
35: }; // end LinkedQueue
37: #include "LinkedQueue.cpp"
38: #endif