[#bsl-priority_queue-034] = xref:bsl.adoc[bsl]::priority_queue :relfileprefix: ../ :mrdocs: Highest‐priority‐first priority queue adapter over a container of `VALUE` elements. == 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; ---- == Description 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. == 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`] | Emplace a newly constructed element into this priority queue. | 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 highest‐priority element from this priority queue. | xref:bsl/priority_queue-034/push-05.adoc[`push`] | `push` overloads | xref:bsl/priority_queue-034/push_range.adoc[`push_range`] | Insert the elements of the specified `range` into this priority queue. | 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 `other`. | xref:bsl/priority_queue-034/top.adoc[`top`] | Return a reference to the highest‐priority element. | 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 iterators supplied to the constructor of `priority_queue`. | 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`. | 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`. | 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`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/swap-07d.adoc[`swap`] | Exchange the container and comparator of `a` with those of `b`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#