C++ Codes
Algorithms
Algorithm Analysis in C++
Beginners
Code Snippets
Graphics
Data Structures
File Manipulation
Games
Mathematics
Miscellaneous
Visual C++ Library
C++ > Visual C++ 5.0 Standard C++ Library sample source codes
Priority queue - container adaptor which allows use of any sequential
Priority queue - container adaptor which allows use of any sequential priority_queue Header <queue> Priority_queue is a container adaptor which allows use of any sequential container with a random access iterator to maintain a sorted collection of items. You can specify a comparator which is used to sort the items. The priority_queue has a single data member, Cont c. This data member defines the container that holds the priority. The container class is required to define the following public members. typedef T value_type; typedef T0 size_type; Cont(const A& al); Cont(InIt first, InIt last, const allocator_type& al); bool empty() const; size_type size() const; allocator_type get_allocator() const; const value_type& front() const; value_type& front(); void push_back(const value_type& x); void pop_back(); Here, T0 is an unspecified type that meets the stated requirements. The priority_queue adaptor allows a container to be treated like a heap. A heap is a sequence of elements organized like a binary tree. Every heap element corresponds to a tree node. Every element in the heap satisfies the following: every element is less than or equal to its parent. The largest element is stored in the root, and all children hold progressively smaller values.
Privacy Policy
|
Link to Us
|
Links