Standard C++ Library Class Reference
Description
priority_queue is a container adaptor which allows a container to act as a priority queue. This
means that the item with the highest priority, as determined by either the default comparison
operator (operator <) or the comparison Compare, is brought to the front of the queue whenever
anything is pushed onto or popped off the queue.
priority_queue adapts any container that provides front(), push_back() and pop_back(). In
particular, deque, list, and vector can be used.
Interface
template <class T,
class Container = vector<T>,
class Compare = less<typename Container::value_type>,
class Allocator = allocator>
class priority_queue {
public:
// typedefs
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Allocator allocator_type;
// Construct
explicit priority_queue (const Compare& = Compare(),
const Allocator&=Allocator());
template <class InputIterator>
priority_queue (InputIterator first,
InputIterator last,
const Compare& = Compare(),
const Allocator& = Allocator());
allocator_type get_allocator() const;
bool empty () const;
size_type size () const;
const value_type& top () const;
void push (const value_type&);
void pop();
};
Constructors
explicit priority_queue (const Compare& x = Compare(),
const Allocator& alloc = Allocator());
Default constructor. Constructs a priority queue that uses Container for its underlying
implementation, x as its standard for determining priority, and the allocator alloc for all
storage management.