.TH "std::priority_queue< _Tp, _Sequence, _Compare >" 3cxx "Wed Jul 14 2021" "libstdc++" \" -*- nroff -*- .ad l .nh .SH NAME std::priority_queue< _Tp, _Sequence, _Compare > \- A standard container automatically sorting its contents\&. .SH SYNOPSIS .br .PP .SS "Public Types" .in +1c .ti -1c .RI "typedef _Sequence::const_reference \fBconst_reference\fP" .br .ti -1c .RI "typedef _Sequence \fBcontainer_type\fP" .br .ti -1c .RI "typedef _Sequence::reference \fBreference\fP" .br .ti -1c .RI "typedef _Sequence::size_type \fBsize_type\fP" .br .ti -1c .RI "typedef _Compare \fBvalue_compare\fP" .br .ti -1c .RI "typedef _Sequence::value_type \fBvalue_type\fP" .br .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "template, is_default_constructible<_Seq>>::value>::type> \fBpriority_queue\fP ()" .br .RI "Default constructor creates no elements\&. " .ti -1c .RI "template \fBpriority_queue\fP (_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Sequence &__s)" .br .RI "Builds a queue from a range\&. " .ti -1c .RI "template \fBpriority_queue\fP (_InputIterator __first, _InputIterator __last, const _Compare &__x=_Compare(), _Sequence &&__s=_Sequence())" .br .ti -1c .RI "template> \fBpriority_queue\fP (const _Alloc &__a)" .br .ti -1c .RI "template> \fBpriority_queue\fP (const _Compare &__x, _Sequence &&__c, const _Alloc &__a)" .br .ti -1c .RI "\fBpriority_queue\fP (const _Compare &__x, _Sequence &&__s=_Sequence())" .br .ti -1c .RI "template> \fBpriority_queue\fP (const _Compare &__x, const _Alloc &__a)" .br .ti -1c .RI "template> \fBpriority_queue\fP (const _Compare &__x, const _Sequence &__c, const _Alloc &__a)" .br .ti -1c .RI "\fBpriority_queue\fP (const _Compare &__x, const _Sequence &__s)" .br .ti -1c .RI "template> \fBpriority_queue\fP (const \fBpriority_queue\fP &__q, const _Alloc &__a)" .br .ti -1c .RI "template> \fBpriority_queue\fP (\fBpriority_queue\fP &&__q, const _Alloc &__a)" .br .ti -1c .RI "template void \fBemplace\fP (_Args &&\&.\&.\&. __args)" .br .ti -1c .RI "bool \fBempty\fP () const" .br .ti -1c .RI "void \fBpop\fP ()" .br .RI "Removes first element\&. " .ti -1c .RI "void \fBpush\fP (const value_type &__x)" .br .RI "Add data to the queue\&. " .ti -1c .RI "void \fBpush\fP (value_type &&__x)" .br .ti -1c .RI "size_type \fBsize\fP () const" .br .ti -1c .RI "void \fBswap\fP (\fBpriority_queue\fP &__pq) noexcept(__and_, __is_nothrow_swappable< _Compare > >::value)" .br .ti -1c .RI "const_reference \fBtop\fP () const" .br .in -1c .SS "Protected Attributes" .in +1c .ti -1c .RI "_Sequence \fBc\fP" .br .ti -1c .RI "_Compare \fBcomp\fP" .br .in -1c .SH "Detailed Description" .PP .SS "template, typename _Compare = less> .br class std::priority_queue< _Tp, _Sequence, _Compare >" A standard container automatically sorting its contents\&. .PP \fBTemplate Parameters\fP .RS 4 \fI_Tp\fP Type of element\&. .br \fI_Sequence\fP Type of underlying sequence, defaults to vector<_Tp>\&. .br \fI_Compare\fP Comparison function object type, defaults to less<_Sequence::value_type>\&. .RE .PP This is not a true container, but an \fIadaptor\fP\&. It holds another container, and provides a wrapper interface to that container\&. The wrapper is what enforces priority-based sorting and queue behavior\&. Very few of the standard container/sequence interface requirements are met (e\&.g\&., iterators)\&. .PP The second template parameter defines the type of the underlying sequence/container\&. It defaults to std::vector, but it can be any type that supports \fCfront()\fP, \fCpush_back\fP, \fCpop_back\fP, and random-access iterators, such as std::deque or an appropriate user-defined type\&. .PP The third template parameter supplies the means of making priority comparisons\&. It defaults to \fCless\fP but can be anything defining a strict weak ordering\&. .PP Members not found in \fInormal\fP containers are \fCcontainer_type\fP, which is a typedef for the second Sequence parameter, and \fCpush\fP, \fCpop\fP, and \fCtop\fP, which are standard queue operations\&. .PP \fBNote\fP .RS 4 No equality/comparison operators are provided for priority_queue\&. .PP Sorting of the elements takes place as they are added to, and removed from, the priority_queue using the priority_queue's member functions\&. If you access the elements by other means, and change their data such that the sorting order would be different, the priority_queue will not re-sort the elements for you\&. (How could it know to do so?) .RE .PP .PP Definition at line 456 of file stl_queue\&.h\&. .SH "Constructor & Destructor Documentation" .PP .SS "template, typename _Compare = less> template, is_default_constructible<_Seq>>::value>::type> \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::\fBpriority_queue\fP ()\fC [inline]\fP" .PP Default constructor creates no elements\&. .PP Definition at line 514 of file stl_queue\&.h\&. .SS "template, typename _Compare = less> template \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::\fBpriority_queue\fP (_InputIterator __first, _InputIterator __last, const _Compare & __x, const _Sequence & __s)\fC [inline]\fP" .PP Builds a queue from a range\&. .PP \fBParameters\fP .RS 4 \fI__first\fP An input iterator\&. .br \fI__last\fP An input iterator\&. .br \fI__x\fP A comparison functor describing a strict weak ordering\&. .br \fI__s\fP An initial sequence with which to start\&. .RE .PP Begins by copying \fI__s\fP, inserting a copy of the elements from \fI\fP[first,last) into the copy of \fI__s\fP, then ordering the copy according to \fI__x\fP\&. .PP For more information on function objects, see the documentation on \fBfunctor base classes\fP\&. .PP Definition at line 586 of file stl_queue\&.h\&. .SH "Member Function Documentation" .PP .SS "template, typename _Compare = less> bool \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::empty () const\fC [inline]\fP" Returns true if the queue is empty\&. .PP Definition at line 612 of file stl_queue\&.h\&. .SS "template, typename _Compare = less> void \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::pop ()\fC [inline]\fP" .PP Removes first element\&. This is a typical queue operation\&. It shrinks the queue by one\&. The time complexity of the operation depends on the underlying sequence\&. .PP Note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called\&. .PP Definition at line 675 of file stl_queue\&.h\&. .SS "template, typename _Compare = less> void \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::push (const value_type & __x)\fC [inline]\fP" .PP Add data to the queue\&. .PP \fBParameters\fP .RS 4 \fI__x\fP Data to be added\&. .RE .PP This is a typical queue operation\&. The time complexity of the operation depends on the underlying sequence\&. .PP Definition at line 640 of file stl_queue\&.h\&. .SS "template, typename _Compare = less> size_type \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::size () const\fC [inline]\fP" Returns the number of elements in the queue\&. .br .PP Definition at line 617 of file stl_queue\&.h\&. .SS "template, typename _Compare = less> const_reference \fBstd::priority_queue\fP< _Tp, _Sequence, _Compare >::top () const\fC [inline]\fP" Returns a read-only (constant) reference to the data at the first element of the queue\&. .PP Definition at line 625 of file stl_queue\&.h\&. .SH "Author" .PP Generated automatically by Doxygen for libstdc++ from the source code\&.