[#bsl-priority_queue-034]
= xref:bsl.adoc[bsl]::priority&lowbar;queue
:relfileprefix: ../
:mrdocs:

This class is a value&hyphen;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&hyphen;priority&hyphen;first priority queue data structure, where the priorities of elements are compared by a comparator of the template parameter type, `COMPARATOR`&period; The container object held by a `priority&lowbar;queue` class object is referenced as `c` in the following documentation&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;priorityqueue&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE,
    class CONTAINER = xref:bsl/vector-00d.adoc[vector&lt;VALUE&gt;],
    class COMPARATOR = std::less&lt;CONTAINER::value&lowbar;type&gt;&gt;
class priority&lowbar;queue;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/priority_queue-034/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias to `CONTAINER&colon;&colon;const&lowbar;reference`&period;
| xref:bsl/priority_queue-034/container_type.adoc[`container&lowbar;type`] 
| This `typedef` is an alias for the adapted container type&period;
| xref:bsl/priority_queue-034/reference.adoc[`reference`] 
| This `typedef` is an alias to `CONTAINER&colon;&colon;reference`&period;
| xref:bsl/priority_queue-034/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to `CONTAINER&colon;&colon;size&lowbar;type`&period;
| xref:bsl/priority_queue-034/value_compare.adoc[`value&lowbar;compare`] 
| This `typedef` is an alias for the element comparison type&period;
| xref:bsl/priority_queue-034/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to `CONTAINER&colon;&colon;value&lowbar;type`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/priority_queue-034/2constructor-0d7.adoc[`priority&lowbar;queue`]         [.small]#[constructor]#
| Constructors
| xref:bsl/priority_queue-034/operator_assign-05.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/priority_queue-034/emplace.adoc[`emplace`] 
| Insert into this priority queue a newly created `value&lowbar;type` object, constructed by forwarding the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type`&period; In effect, performs `c&period;emplace&lowbar;back(FORWARD(Args,args)&period;&period;&period;)&semi;`&period;
| xref:bsl/priority_queue-034/empty.adoc[`empty`] 
| Return `true` if this `priority&lowbar;queue` object contains no elements, and `false` otherwise&period; In effect, performs `return c&period;empty()&semi;`&period;
| xref:bsl/priority_queue-034/pop.adoc[`pop`] 
| Remove the top element from this `priority&lowbar;queue` object that has the highest priority&period; In effect, performs `c&period;pop&lowbar;back()&semi;`&period; The behavior is undefined if there is currently no elements in this object&period;
| xref:bsl/priority_queue-034/push-05.adoc[`push`] 
| Insert the specified `value` into this priority queue&period; In effect, performs `c&period;push&lowbar;back(value)&semi;`&period;
| xref:bsl/priority_queue-034/push_range.adoc[`push&lowbar;range`] 
| Insert the elements of the specified `range` into this priority queue&period; 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`&period;
| xref:bsl/priority_queue-034/size.adoc[`size`] 
| Return the number of elements in this `priority&lowbar;queue` object&period; In effect, performs `return c&period;size()`&period;
| xref:bsl/priority_queue-034/swap.adoc[`swap`] 
| Efficiently exchange the value of this object with the value of the specified `other` object&period; In effect, performs `using bsl&colon;&colon;swap&semi; swap(c, other&period;c)&semi;`&period;
| xref:bsl/priority_queue-034/top.adoc[`top`] 
| Return a reference providing non&hyphen;modifiable access to the element having the highest priority in this `priority&lowbar;queue` object&period; In effect, performs `return c&period;front()`&period; The behavior is undefined if the priority queue is empty&period;
| xref:bsl/priority_queue-034/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;priority&lowbar;queue, UsesBslmaAllocator, BloombergLP&colon;&colon;bslma&colon;&colon;UsesBslmaAllocator&lt;container&lowbar;type&gt;&colon;&colon;value&gt;`] 
| Nested trait declaration for `UsesBslmaAllocator`&period;
|===


== Protected Data Members

[cols="1,4"]
|===
| Name| Description
| xref:bsl/priority_queue-034/c.adoc[`c`] 
| Underlying container holding the priority&hyphen;queue elements&period;
| xref:bsl/priority_queue-034/comp.adoc[`comp`] 
| Comparator that defines the priority order of elements&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/priority_queue-044.adoc[`priority&lowbar;queue&lt;VALUE&gt;`] 
| Deduce the template parameter `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `priority&lowbar;queue`&period;
| xref:bsl/priority_queue-03e.adoc[`priority&lowbar;queue&lt;VALUE, CONTAINER, COMPARATOR&gt;`] 
| Deduce the template parameter `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `priority&lowbar;queue`&period; Deduce the template parameters `CONTAINER` and `COMPARATOR` from the other parameters passed to the constructor&period;
| xref:bsl/priority_queue-0432.adoc[`priority&lowbar;queue&lt;t&lowbar;TYPE, vector&lt;t&lowbar;TYPE&gt;, t&lowbar;COMPARATOR&gt;`] 
| Deduce the template parameters `VALUE` and `COMPARATOR` from the parameters supplied to the constructor of `priority&lowbar;queue`&period;
| xref:bsl/priority_queue-0d.adoc[`priority&lowbar;queue&lt;t&lowbar;TYPE, vector&lt;t&lowbar;TYPE, t&lowbar;ALLOCATOR&gt;&gt;`] 
| Deduce the template parameters `VALUE` and `ALLOCATOR` from the parameters supplied to the constructor of `priority&lowbar;queue`&period; This deduction guide does not participate unless the `t&lowbar;ALLOCATOR` parameter meets the requirements for a standard allocator&period;
| xref:bsl/priority_queue-03d.adoc[`priority&lowbar;queue&lt;t&lowbar;TYPE, vector&lt;t&lowbar;TYPE, t&lowbar;ALLOCATOR&gt;, t&lowbar;COMPARATOR&gt;`] 
| Deduce the template parameters `VALUE`, `COMPARATOR`, and `ALLOCATOR` from the parameters supplied to the constructor of `priority&lowbar;queue`&period; This deduction guide does not participate if the `t&lowbar;ALLOCATOR` parameter does not meet the requirements for a standard allocator or the `t&lowbar;COMPARATOR` parameter meets the requirements for a standard allocator&period;
| xref:bsl/priority_queue-0e.adoc[`priority&lowbar;queue&lt;CONTAINER::value&lowbar;type, CONTAINER, COMPARATOR&gt;`] 
| Deduce the template parameter `VALUE` and `CONTAINER` from the parameters supplied to the constructor of `priority&lowbar;queue`&period;
| xref:bsl/priority_queue-0430.adoc[`priority&lowbar;queue&lt;CONTAINER::value&lowbar;type, CONTAINER, COMPARATOR&gt;`] 
| Deduce the template parameters `VALUE`, `CONTAINER` and `COMPARATOR` from the parameters supplied to the constructor of `priority&lowbar;queue`&period; This deduction guide does not participate unless the supplied allocator is convertible to the underlying container&apos;s `allocator&lowbar;type`&period;
|===


== 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&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
