Priority QueuesThe data type p_queue can be used to store objects of an arbitrary type I together with an associated priority of a linearly ordered type P (int, string, In a Priority Queue the object with the minimum priority can be accessed very efficiently. ExampleThe following program reads a sequence of doubles from standard input (cin) and stores them in a Priority Queue. The priority type is double and the information type is int. (The information type is not used in the example.) Then it repeatedly extracts the minimum element from the queue until the queue is empty. In this way the input sequence is sorted in increasing order.#include <LEDA/core/p_queue.h> int main() { leda::p_queue<double,int> Q; //priority type double, information type is irrelevant std::cout << "Please insert double numbers"; Application Areas
Strengths
Disadvantages
Tips
|
See also:Other data types with key of linearly ordered type: Data types with key of type pointer, item, or int: Maps. Data types with key of hashed type: Hashing Arrays. Manual Entries: |