// ------------------------------------------------------------------------ // Priority queues: derived from Container-<--Linear-<--PQueue // A. Fischer June 9, 2001 file: pqueue.hpp // ------------------------------------------------------------------------ #pragma once #include "ordered.hpp" #include "linear.hpp" template class PQueue : public Linear { public: // ----------------------------------------------------- PQueue(){} virtual ~PQueue(){ cout << "PQueue destructor called"; } // keyword "virtual" not needed here but doesn't hurt since // class already has (inherited) virtual methods void focus(){ Linear::reset(); } // Priority queue deletion is at the head. protected: // ------------------------ Insert new Cell in ascending sorted order. void insert( Cell* cp ) { for (Linear::reset(); !Linear::end(); ++*this) { // locate insertion spot. if ( !(*this < cp) )break; } Linear::insert( cp ); // do the insertion. } };