// pqsorter.h - derived class of Sorter that uses a PQ // to do the sorting; all completely implemented inline // cmc, 11/1/2013 #ifndef PQSORTER_H #define PQSORTER_H #include "sorter.h" #include "pq.h" class PQSorter : public Sorter { public: // only constructor requires concrete PQ PQSorter(PQ &q) : queue(q) { } // inherited as virtual, but will sort with the PQ virtual void sort(double x[], int n) { int i; for (i=0; i=0; i--) x[i] = queue.get(); } private: // note: the queue is a reference variable PQ &queue; }; #endif