// Created by Frank M. Carrano and Tim Henry. // Copyright (c) 2013 __Pearson Education__. All rights reserved. /** Heap-based implementation of the ADT priority queue. Listing 17-4. @file Heap_PriorityQueue.cpp */ #include "Heap_PriorityQueue.h" template Heap_PriorityQueue::Heap_PriorityQueue() { ArrayMaxHeap(); } // end constructor template bool Heap_PriorityQueue::isEmpty() const { return ArrayMaxHeap::isEmpty(); } // end isEmpty template bool Heap_PriorityQueue::add(const ItemType& newEntry) { return ArrayMaxHeap::add(newEntry); } // end add template bool Heap_PriorityQueue::remove() { return ArrayMaxHeap::remove(); } // end remove template ItemType Heap_PriorityQueue::peek() const throw(PrecondViolatedExcep) { try { return ArrayMaxHeap::peekTop(); } catch (PrecondViolatedExcep e) { throw PrecondViolatedExcep("Attempted peek into an empty priority queue."); } // end try/catch } // end peek