bsl::priority_queue

This class is a value-semantic class template, adapting a container of the (template parameter) type CONTAINER, that holds elements of the (template parameter) type VALUE, to provide a highest-priority-first priority queue data structure, where the priorities of elements are compared by a comparator of the template parameter type, COMPARATOR. The container object held by a priority_queue class object is referenced as c in the following documentation.

Synopsis

Declared in <bslstl_priorityqueue.h>

template<
    class VALUE,
    class CONTAINER = vector<VALUE>,
    class COMPARATOR = std::less<CONTAINER::value_type>>
class priority_queue;

Type Aliases

NameDescription
const_reference This typedef is an alias to CONTAINER::const_reference.
container_type This typedef is an alias for the adapted container type.
reference This typedef is an alias to CONTAINER::reference.
size_type This typedef is an alias to CONTAINER::size_type.
value_compare This typedef is an alias for the element comparison type.
value_type This typedef is an alias to CONTAINER::value_type.

Member Functions

NameDescription
priority_queue [constructor]Constructors
operator= Assignment operators
emplace Insert into this priority queue a newly created value_type object, constructed by forwarding the specified (variable number of) args to the corresponding constructor of value_type. In effect, performs c.emplace_back(FORWARD(Args,args)...);.
empty Return true if this priority_queue object contains no elements, and false otherwise. In effect, performs return c.empty();.
pop Remove the top element from this priority_queue object that has the highest priority. In effect, performs c.pop_back();. The behavior is undefined if there is currently no elements in this object.
push Insert the specified value into this priority queue. In effect, performs c.push_back(value);.
push_range Insert the elements of the specified range into this priority queue. Note that range must meet the requirements of an input range and the values from range must have a type matching or convertible to (template parameter) VALUE.
size Return the number of elements in this priority_queue object. In effect, performs return c.size().
swap Efficiently exchange the value of this object with the value of the specified other object. In effect, performs using bsl::swap; swap(c, other.c);.
top Return a reference providing non-modifiable access to the element having the highest priority in this priority_queue object. In effect, performs return c.front(). The behavior is undefined if the priority queue is empty.
operator BloombergLP::bslmf::NestedTraitDeclaration<priority_queue, UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator<container_type>::value> Nested trait declaration for UsesBslmaAllocator.

Protected Data Members

NameDescription
c Underlying container holding the priority-queue elements.
comp Comparator that defines the priority order of elements.

Deduction Guides

NameDescription
priority_queue<VALUE> Deduce the template parameter VALUE from the value_type of the iterators supplied to the constructor of priority_queue.
priority_queue<VALUE, CONTAINER, COMPARATOR> Deduce the template parameter VALUE from the value_type of the iterators supplied to the constructor of priority_queue. Deduce the template parameters CONTAINER and COMPARATOR from the other parameters passed to the constructor.
priority_queue<t_TYPE, vector<t_TYPE>, t_COMPARATOR> Deduce the template parameters VALUE and COMPARATOR from the parameters supplied to the constructor of priority_queue.
priority_queue<t_TYPE, vector<t_TYPE, t_ALLOCATOR>> Deduce the template parameters VALUE and ALLOCATOR from the parameters supplied to the constructor of priority_queue. This deduction guide does not participate unless the t_ALLOCATOR parameter meets the requirements for a standard allocator.
priority_queue<t_TYPE, vector<t_TYPE, t_ALLOCATOR>, t_COMPARATOR> Deduce the template parameters VALUE, COMPARATOR, and ALLOCATOR from the parameters supplied to the constructor of priority_queue. This deduction guide does not participate if the t_ALLOCATOR parameter does not meet the requirements for a standard allocator or the t_COMPARATOR parameter meets the requirements for a standard allocator.
priority_queue<CONTAINER::value_type, CONTAINER, COMPARATOR> Deduce the template parameter VALUE and CONTAINER from the parameters supplied to the constructor of priority_queue.
priority_queue<CONTAINER::value_type, CONTAINER, COMPARATOR> Deduce the template parameters VALUE, CONTAINER and COMPARATOR from the parameters supplied to the constructor of priority_queue. This deduction guide does not participate unless the supplied allocator is convertible to the underlying container's allocator_type.

Non-Member Functions

NameDescription
swapExchange the container and comparator of the specified a object with the container and comparator of the specified b object.