This is more of a note to myself, but I've had to look up how to initialize a priority queue with a custom comparison function in C++ too many times (and it's always hard to find). It's really not hard, there's just not one good online source for the STL (someone please point one out if there is - or even a good pocket reference type book). Anyway, here's the code.... not too hard:
#include "event.h" #include <queue> using std::priority_queue; class greater { public: int operator() (Event *x, Event *y) { return *x > *y; } }; priority_queue< Event *, vector<Event *>, greater > _event_queue;
good post - changed from Event to my class type and it worked perfectly :) Thanks for putting it up
hello sir, i m looking for the source code for t implementation of the Priority Queue in c language.. so plz if u hv sme thnG related to it kindally send me!! Thnxs!
Hello, one year ago today it seems you posted this. And today I am taking advantage of this, its works quite brilliantly, thanks so much!
hello sir I would like to get a source code of c language which implimented as priority gueue