__GNU_PBDS::PRIORITY_QUEUE(3)
πΈ NAME πΈ
__gnu_pbds::priority_queue< _Tv, Cmp_Fn, Tag, _Alloc > β bestie, it's a priority queue, but make it policy-based π
This page lives in the Library Functions Manual, section 3, and it's all about the libstdc++ <priority_queue.hpp> glow-up. Periodt.
β¨ SYNOPSIS β¨
#include <priority_queue.hpp>
π Public Types π
Okay so here's the whole type roster, no skips, all of them:
typedef _Alloc allocator_typeβ the allocator, but with a cuter nametypedef Cmp_Fn cmp_fnβ your comparison functor's alias eratypedef base_type::const_iterator const_iteratorβ read-only iterator, main character but can't touch anythingtypedef __rebind_va::const_pointer const_pointerβ const pointer, iconictypedef __rebind_va::const_reference const_referenceβ const reference, obsessedtypedef Tag container_categoryβ theTagtelling everyone which heap vibe this container is ontypedef allocator_type::difference_type difference_typeβ difference type, for when you need to know how fartypedef base_type::iterator iteratorβ the regular iterator, it can touch thingstypedef base_type::point_const_iterator point_const_iteratorβ const point iterator, iykyktypedef base_type::point_iterator point_iteratorβ point iterator, the one that points at your element fr frtypedef __rebind_va::pointer pointerβ pointer πtypedef __rebind_va::reference referenceβ reference πtypedef allocator_type::size_type size_typeβ size type, for all your counting needstypedef _Tv value_typeβ the actual value type, the moment
π¦ Public Member Functions π¦
priority_queue (const cmp_fn &r_cmp_fn)β constructor that takes some policy objects.r_cmp_fngets copied by theCmp_Fnobject of the container object. Not a drill.priority_queue (const priority_queue &other)β copy constructor, doing a little duplicatetemplate<typename It> priority_queue (It first_it, It last_it)β constructor taking __iterators to a range ofvalue_types. Thevalue_typesbetweenfirst_itandlast_itget inserted into the container object. Slay.template<typename It> priority_queue (It first_it, It last_it, const cmp_fn &r_cmp_fn)β constructor taking __iterators to a range ofvalue_typesand some policy objects. Thevalue_typesbetweenfirst_itandlast_itget inserted into the container object, andr_cmp_fngets copied by thecmp_fnobject of the container object.priority_queue & operator= (const priority_queue &other)β assignment operator, passing the vibe alongvoid swap (priority_queue &other)β swap, the classic two-way trade π€
π Detailed Description π
template<typename _Tv, typename Cmp_Fn = std::less<_Tv>, typename Tag =
pairing_heap_tag, typename _Alloc = std::allocator<char>>
class __gnu_pbds::priority_queue< _Tv, Cmp_Fn, Tag, _Alloc >
"A priority queue composed of one specific heap policy." That's the whole premise bestie, one queue, one heap policy, committed relationship energy.
π Template Parameters π
_Tvβ value type. The thing you're storing.Cmp_Fnβ comparison functor. It decides who's actually more important.Tagβ instantiating data structure type, seecontainer_tag. This is the vibe selector._Allocβ allocator type.
Base is dispatched at compile time via Tag, from the following choices: binary_heap_tag, binomial_heap_tag, pairing_heap_tag, rc_binomial_heap_tag, thin_heap_tag
Base choices are: detail::binary_heap, detail::binomial_heap, detail::pairing_heap, detail::rc_binomial_heap, detail::thin_heap.
π«Ά Constructor & Destructor Documentation π«Ά
priority_queue (const cmp_fn &r_cmp_fn) β constructor #1
template<typename _Tv, typename Cmp_Fn = std::less<_Tv>, typename Tag =
pairing_heap_tag, typename _Alloc = std::allocator<char>>
__gnu_pbds::priority_queue< _Tv, Cmp_Fn, Tag, _Alloc >::priority_queue
(const cmp_fn & r_cmp_fn) [inline]
Constructor taking some policy objects. r_cmp_fn will be copied by the Cmp_Fn object of the container object. β¨
priority_queue (It first_it, It last_it) β constructor #2
template<typename _Tv, typename Cmp_Fn = std::less<_Tv>, typename Tag =
pairing_heap_tag, typename _Alloc = std::allocator<char>>
template<typename It> __gnu_pbds::priority_queue< _Tv, Cmp_Fn, Tag,
_Alloc >::priority_queue (It first_it, It last_it) [inline]
Constructor taking __iterators to a range of value_types. The value_types between first_it and last_it will be inserted into the container object. π
priority_queue (It first_it, It last_it, const cmp_fn &r_cmp_fn) β constructor #3
template<typename _Tv, typename Cmp_Fn = std::less<_Tv>, typename Tag =
pairing_heap_tag, typename _Alloc = std::allocator<char>>
template<typename It> __gnu_pbds::priority_queue< _Tv, Cmp_Fn, Tag,
_Alloc >::priority_queue (It first_it, It last_it, const cmp_fn &
r_cmp_fn) [inline]
Constructor taking __iterators to a range of value_types and some policy objects. The value_types between first_it and last_it will be inserted into the container object. r_cmp_fn will be copied by the cmp_fn object of the container object. Two-for-one, we love to see it. π
Heads up bestie: the description literally reads "and some policy objects The value_types..." β no period in the original, so no period from me. Fidelity is the moment.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. Not a human, just a very dedicated documentation robot doing its thing. π€
Okay that's the whole page, and as a lil sign-off: this came from libstdc++, it's filed under __gnu_pbds..., _Alloc >(3) in the Library Functions Manual, and there's no date on it so we're just gonna say timeless π mwah, go forth and heapify π
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms