Next : Iterator Adaptors, Previous : Queue, Top : Table of Contents
priority_queue |
Container Adaptor |
Any sequence (Sequences) with random access iterator and supporting operations front, push_back and pop_back can be used to instantiate priority_queue. In particular, vector (Vector) and deque (Deque) can be used.
value_type | Typedef on priority_queue |
size_type | Typedef on priority_queue |
priority_queue (const Compare& x = Compare()) | Constructor on priority_queue |
priority_queue (InputIterator first, InputIterator last, const Compare& x = Compare()) | Constructor on priority_queue |
bool empty () | Method on priority_queue |
size_type size () | Method on priority_queue |
value_type& top () | Method on priority_queue |
void push (value_type& x) | Method on priority_queue |
void pop () | Method on priority_queue |
template> class priority_queue { public: typedef Container::value_type value_type; typedef Container::size_type size_type; protected: Container c; Compare comp; public: priority_queue(const Compare& x = Compare()) : c(), comp(x) {} template priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare()) : c(first, last), comp(x) { make_heap(c.begin(), c.end(), comp); } bool empty() const { return c.empty(); } size_type size() const { return c.size(); } const value_type& top() const { return c.front(); } void push(const value_type& x) { c.push_back(x); push_heap(c.begin(), c.end(), comp); } void pop() { pop_heap(c.begin(), c.end(), comp); c.pop_back(); } }; // no equality is provided
|
|