//================================================================ // This module provides class PQueue, a kind of priority // queues. The constructor creates an empty queue. Objects of // class PQueue have the following capabilities. // // q.insert(p,e) Insert Event object e (given by a pointer to the object) // into priority queue q, with priority p. The priority // has type double. // // q.remove(p,e) Remove the event object from priority queue q // that has the smallest priority. Store its priority // into variable p, and store a pointer to the event object // into variable e. An attempt to remove an object // from an empty queue is an error, and causes the // program to stop. // // q.isEmpty() Return true if q is empty, false if not. // // q.print() Print all of the objects in priority queue q, // in nondecreasing order of priority. //================================================================ #ifndef PQUEUE_H #define PQUEUE_H #include "event.h" class PQueue { public: PQueue(); void insert(double priority, Event* obj); void remove(double& priority, Event*& obj); bool isEmpty() const; void print() const; private: struct PQCell; PQCell* ptr; void insert(PQCell*& p, double priority, Event* obj); }; #endif