priority_queue


With this adapter, you can use any sequential container that has a random access iterator to maintain a sorted collection of items. Use this adapter to specify a comparator to sort the items.

Library

Standards<ToolKit>

Declaration


#include <queue>

template< class T, class Container, class Compare >
class priority_queue

Interface

Constructor
priority_queue()
Constructs an empty priority queue that orders elements using the comparator Compare() (default less< T > ), and using Container (default vector< T > ) as the queue's internal data structure. The allocator Container::allocator_type() is used to manage storage.
Constructor
explicit priority_queue( const Compare& compare )
Constructs an empty priority queue that orders elements using compare, and uses Container (default vector< T > ) as the queue's internal data structure . The allocator Container::allocator_type() is used to manage storage.
Constructor
explicit priority_queue( const Compare& compare , const typename Container::allocator_type& alloc )
Constructs an empty priority queue that orders elements using compare, and uses Container (default vector< T > ) as the queue's internal data structure .
Constructor
priority_queue( const T* first , const T* last )
Constructs a priority queue that contains a copy of elements from the range [ first , last ) , using the comparator Compare() (default less< T > ) to order the container. Container (default vector< T > ) is used as the queue's internal data structure.
Constructor
priority_queue( const T* first , const T* last , const Compare& compare )
Constructs a priority queue that contains a copy of elements from the range [ first , last ) , using compare to order the container. Container (default vector< T > ) is used as the queue's internal data structure.
Destructor
~priority_queue()
Destroys the queue and erases all of its items.
empty
bool empty() const
Returns true if the queue contains no elements.
get_allocator
Container::allocator_type get_allocator() const
Returns a copy of the allocator the queue uses to manage storage.
pop
void pop()
Erases the queue's top element.
push
void push( const T& value )
Pushes a copy of value .
size
size_type size() const
Returns the number of entries in the queue.
top
const T& top() const
Returns a reference to the queue's top element.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.