class SL_PriorityQueue
1: // Created by Frank M. Carrano and Timothy M. Henry.
2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
4: // Listing 14-6.
6: /** ADT priority queue: ADT sorted list implementation.
7: @file SL_PriorityQueue.h */
9: #ifndef PRIORITY_QUEUE_
10: #define PRIORITY_QUEUE_
12: #include "PriorityQueueInterface.h"
13: #include "LinkedSortedList.h"
14: #include "PrecondViolatedExcept.h"
15: #include <memory>
17: template<class ItemType>
18: class SL_PriorityQueue : public PriorityQueueInterface<ItemType>
19: {
20: private:
21: std::unique_ptr<LinkedSortedList<ItemType>> slistPtr; // Pointer to sorted list of
22: // items in the priority queue
24: public:
25: SL_PriorityQueue();
26: SL_PriorityQueue(const SL_PriorityQueue& pq);
27: ~SL_PriorityQueue();
29: bool isEmpty() const;
30: bool enqueue(const ItemType& newEntry);
31: bool dequeue();
33: /** @throw PrecondViolatedExcept if priority queue is empty. */
34: ItemType peek() const throw(PrecondViolatedExcept);
35: }; // end SL_PriorityQueue
36: #include "SL_PriorityQueue.cpp"
37: #endif