Bounded Priority QueuesThe data type b_priority_queue is a variant of the data type Priority Queue. It can be used to store objects of an arbitrary type I together with an associated priority from a fixed interval [a..b] of ints.ExampleThe following program shows how to use b_priority_queue.#include <LEDA/core/b_prio.h> #include <LEDA/core/string.h> int main() { leda::b_priority_queue<double> Q(1,5); //bounded priority queue with priorities between 1 and 5 Q.insert(2.5,3); Q.insert(1.5,2); Q.insert(0.7,1); Q.insert(4.4,5); Q.insert(3.8,4); while (!Q.empty()) std::cout << Q.del_min() << std::endl; return 0; } Strengths
Disadvantages
TipUse Bounded Priority Queues to replace Priority Queue if your keys are from a fixed interval of ints. |
See also:Manual Entries: Manual Page Bounded Priority Queues |