class ArrayQueue
1: // Created by Frank M. Carrano and Timothy M. Henry.
2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
4: // Listing 14-4.
6: /** ADT queue: Circular array-based implementation.
7: @file ArrayQueue.h */
9: #ifndef ARRAY_QUEUE_
10: #define ARRAY_QUEUE_
11: #include "QueueInterface.h"
12: #include "PrecondViolatedExcept.h"
14: template<class ItemType>
15: class ArrayQueue : public QueueInterface<ItemType>
16: {
17: private:
18: static const int DEFAULT_CAPACITY = 50;
19: ItemType items[DEFAULT_CAPACITY]; // Array of queue items
20: int front; // Index to front of queue
21: int back; // Index to back of queue
22: int count; // Number of items currently in the queue
23:
24: public:
25: ArrayQueue();
26: // Copy constructor and destructor supplied by compiler
27: bool isEmpty() const;
28: bool enqueue(const ItemType& newEntry);
29: bool dequeue();
30:
31: /** @throw PrecondViolatedExcept if queue is empty. */
32: ItemType peekFront() const throw(PrecondViolatedExcept);
33: }; // end ArrayQueue
34: #include "ArrayQueue.cpp"
35: #endif