[#bsl-priority_queue-034] = xref:bsl.adoc[bsl]::priority_queue :relfileprefix: ../ :mrdocs: 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>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class VALUE, class CONTAINER = xref:bsl/vector-00d.adoc[vector<VALUE>], class COMPARATOR = std::less<CONTAINER::value_type>> class priority_queue; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/priority_queue-034/const_reference.adoc[`const_reference`] | This `typedef` is an alias to `CONTAINER::const_reference`. | xref:bsl/priority_queue-034/container_type.adoc[`container_type`] | This `typedef` is an alias for the adapted container type. | xref:bsl/priority_queue-034/reference.adoc[`reference`] | This `typedef` is an alias to `CONTAINER::reference`. | xref:bsl/priority_queue-034/size_type.adoc[`size_type`] | This `typedef` is an alias to `CONTAINER::size_type`. | xref:bsl/priority_queue-034/value_compare.adoc[`value_compare`] | This `typedef` is an alias for the element comparison type. | xref:bsl/priority_queue-034/value_type.adoc[`value_type`] | This `typedef` is an alias to `CONTAINER::value_type`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/priority_queue-034/2constructor-0d7.adoc[`priority_queue`] [.small]#[constructor]# | Constructors | xref:bsl/priority_queue-034/operator_assign-05.adoc[`operator=`] | Assignment operators | xref:bsl/priority_queue-034/emplace.adoc[`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)...);`. | xref:bsl/priority_queue-034/empty.adoc[`empty`] | Return `true` if this `priority_queue` object contains no elements, and `false` otherwise. In effect, performs `return c.empty();`. | xref:bsl/priority_queue-034/pop.adoc[`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. | xref:bsl/priority_queue-034/push-05.adoc[`push`] | Insert the specified `value` into this priority queue. In effect, performs `c.push_back(value);`. | xref:bsl/priority_queue-034/push_range.adoc[`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`. | xref:bsl/priority_queue-034/size.adoc[`size`] | Return the number of elements in this `priority_queue` object. In effect, performs `return c.size()`. | xref:bsl/priority_queue-034/swap.adoc[`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);`. | xref:bsl/priority_queue-034/top.adoc[`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. | xref:bsl/priority_queue-034/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<priority_queue, UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator<container_type>::value>`] | Nested trait declaration for `UsesBslmaAllocator`. |=== == Protected Data Members [cols="1,4"] |=== | Name| Description | xref:bsl/priority_queue-034/c.adoc[`c`] | Underlying container holding the priority‐queue elements. | xref:bsl/priority_queue-034/comp.adoc[`comp`] | Comparator that defines the priority order of elements. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/priority_queue-044.adoc[`priority_queue<VALUE>`] | Deduce the template parameter `VALUE` from the `value_type` of the iterators supplied to the constructor of `priority_queue`. | xref:bsl/priority_queue-03e.adoc[`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. | xref:bsl/priority_queue-0432.adoc[`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`. | xref:bsl/priority_queue-0d.adoc[`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. | xref:bsl/priority_queue-03d.adoc[`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. | xref:bsl/priority_queue-0e.adoc[`priority_queue<CONTAINER::value_type, CONTAINER, COMPARATOR>`] | Deduce the template parameter `VALUE` and `CONTAINER` from the parameters supplied to the constructor of `priority_queue`. | xref:bsl/priority_queue-0430.adoc[`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 [cols="1,4"] |=== | Name| Description | xref:bsl/swap-07d.adoc[`swap`] | Exchange the container and comparator of the specified `a` object with the container and comparator of the specified `b` object. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#