Source of Listing17-3.h


  1: //  Created by Frank M. Carrano and Timothy M. Henry.
  2: //  Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.

  4: // Listing 17-3.

  6: /** ADT priority queue: Heap-based implementation.
  7:  @file HeapPriorityQueue.h */

  9: #ifndef HEAP_PRIORITY_QUEUE_
 10: #define HEAP_PRIORITY_QUEUE_

 12: #include "ArrayMaxHeap.h"
 13: #include "PriorityQueueInterface.h"

 15: template<class ItemType>
 16: class Heap_PriorityQueue : public PriorityQueueInterface<ItemType>,
 17:                            private ArrayMaxHeap<ItemType>
 18: {
 19: public:
 20:    Heap_PriorityQueue();
 21:    bool isEmpty() const;
 22:    bool enqueue(const ItemType& newEntry);
 23:    bool dequeue();
 24:    
 25:    /** @pre  The priority queue is not empty. */
 26:    ItemType peekFront() const throw(PrecondViolatedExcept);
 27: }; // end Heap_PriorityQueue

 29: #include "Heap_PriorityQueue.cpp"
 30: #endif