STD::PRIORITY_QUEUE(3cxx)
πΈ NAME πΈ
okay so welcome to the 3cxx manual page for std::priority_queue< _Tp, _Sequence, _Compare > β it's a standard container automatically sorting its contents. It's giving priority-queue main character energy, no cap. π
β¨ SYNOPSIS β¨
#include <queue>
π Public Types π
typedef _Sequence::const_reference const_referencetypedef _Sequence container_typeβ the underlying sequence type, servingcontainer_typerealness.typedef _Sequence::reference referencetypedef _Sequence::size_type size_typetypedef _Compare value_comparetypedef _Sequence::value_type value_type
π«Ά Public Member Functions π«Ά
template<typename _Seq = _Sequence, typename _Requires = typename enable_if<__and_<is_default_constructible<_Compare>, is_default_constructible<_Seq>>::value>::type> priority_queue ()β Default constructor creates no elements.template<typename _InputIterator , typename _Alloc , typename = std::_RequireInputIter<_InputIterator>, typename _Requires = _Uses<_Alloc>> priority_queue (_InputIterator __first, _InputIterator __last, const _Alloc &__alloc)template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x, _Sequence &&__s)template<typename _InputIterator , typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x, _Sequence &&__s, const _Alloc &__alloc)template<typename _InputIterator , typename _Alloc , typename = std::_RequireInputIter<_InputIterator>, typename _Requires = _Uses<_Alloc>> priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Alloc &__alloc)template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Sequence &__s)template<typename _InputIterator , typename _Alloc , typename = std::_RequireInputIter<_InputIterator>, typename _Requires = _Uses<_Alloc>> priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Sequence &__s, const _Alloc &__alloc)template<typename _InputIterator , typename = std::_RequireInputIter<_InputIterator>> priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x=_Compare())β Builds a queue from a range.template<typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (const _Alloc &__a)template<typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (const _Compare &__x, _Sequence &&__c, const _Alloc &__a)priority_queue (const _Compare &__x, _Sequence &&__s=_Sequence())template<typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (const _Compare &__x, const _Alloc &__a)template<typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (const _Compare &__x, const _Sequence &__c, const _Alloc &__a)priority_queue (const _Compare &__x, const _Sequence &__s)template<typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (const priority_queue &__q, const _Alloc &__a)template<typename _Alloc , typename _Requires = _Uses<_Alloc>> priority_queue (priority_queue &&__q, const _Alloc &__a)template<typename... _Args> void emplace (_Args &&... __args)bool empty () constvoid pop ()β Removes first element.void push (const value_type &__x)β Add data to the queue.void push (value_type &&__x)size_type size () constswapwith the exact signature:
void swap (priority_queue &__pq) noexcept(__and_<//c++1z or gnu++11
__is_nothrow_swappable< _Sequence >, __is_nothrow_swappable<
_Compare > >::value)
const_reference top () const
π Protected Attributes π
_Sequence cβ the_Sequencedata member, living its best protected life._Compare compβ the comparison object data member.
π Detailed Description π
template<typename _Tp, typename _Sequence = vector<_Tp>, typename _Compare =
less<typename _Sequence::value_type>>
class std::priority_queue< _Tp, _Sequence, _Compare >"A standard
container automatically sorting its contents.
π Template Parameters π
_Tpβ Type of element._Sequenceβ Type of underlying sequence, defaults tovector<_Tp>._Compareβ Comparison function object type, defaults toless<_Sequence::value_type>.
This is not a true container, but an adaptor. 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).
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 front(), push_back, pop_back, and random-access iterators, such as std::deque or an appropriate user-defined type.
The third template parameter supplies the means of making priority comparisons. It defaults to less<value_type> but can be anything defining a strict weak ordering.
Members not found in normal containers are container_type, which is a typedef for the second Sequence parameter, and push, pop, and top, which are standard queue operations.
β οΈ Note β οΈ
No equality/comparison operators are provided forpriority_queue. Sorting of the elements takes place as they are added to, and removed from, thepriority_queueusing thepriority_queue's member functions. If you access the elements by other means, and change their data such that the sorting order would be different, thepriority_queuewill not re-sort the elements for you. (How could it know to do so?)
π οΈ Constructor & Destructor Documentation π οΈ
πΈ priority_queue () πΈ
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> template<typename _Seq =
_Sequence, typename _Requires = typename
enable_if<__and_<is_default_constructible<_Compare>, is_default_constructible<_Seq>>::value>::type>
std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue ()
[inline]
Default constructor creates no elements. Iconic empty-queue behavior.
π¦ priority_queue (_InputIterator __first, _InputIterator __last, const _Compare & __x = _Compare()) π¦
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> template<typename _InputIterator
, typename = std::_RequireInputIter<_InputIterator>>
std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue
(_InputIterator __first, _InputIterator __last, const _Compare & __x =
_Compare()) [inline]
Builds a queue from a range.
Parameters
__firstβ An input iterator.__lastβ An input iterator.__xβ A comparison functor describing a strict weak ordering.__sβ An initial sequence with which to start.
Begins by copying __s, inserting a copy of the elements from [first,last) into the copy of __s, then ordering the copy according to __x.
For more information on function objects, see the documentation on functor base classes.
π Member Function Documentation π
π«§ empty () const π«§
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> bool std::priority_queue< _Tp,
_Sequence, _Compare >::empty () const [inline]
Returns true if the queue is empty.
Referenced by __gnu_parallel::multiseq_partition(), and __gnu_parallel::multiseq_selection().
π pop () π
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> void std::priority_queue< _Tp,
_Sequence, _Compare >::pop () [inline]
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.
Note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called.
Referenced by __gnu_parallel::multiseq_partition(), and __gnu_parallel::multiseq_selection().
π push (const value_type & __x) π
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> void std::priority_queue< _Tp,
_Sequence, _Compare >::push (const value_type & __x) [inline]
Add data to the queue.
Parameters
__xβ Data to be added.
This is a typical queue operation. The time complexity of the operation depends on the underlying sequence.
Referenced by __gnu_parallel::multiseq_partition(), and __gnu_parallel::multiseq_selection().
π size () const π
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> size_type std::priority_queue<
_Tp, _Sequence, _Compare >::size () const [inline]
Returns the number of elements in the queue.
β top () const β
template<typename _Tp , typename _Sequence = vector<_Tp>, typename _Compare
= less<typename _Sequence::value_type>> const_reference
std::priority_queue< _Tp, _Sequence, _Compare >::top () const [inline]
Returns a read-only (constant) reference to the data at the first element of the queue.
Referenced by __gnu_parallel::multiseq_partition(), and __gnu_parallel::multiseq_selection().
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
okay bestie, that's the whole 3cxx manual page energy. Source/version vibes: libstdc++; footer text: libstdstd::priority_...nce, _Compare >(3cxx); and date-wise, the footer here is just that line, so no extra date is shown. Mwah πβ¨
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms