__GNU_PBDS::TREE(3cxx)
πΈ NAME πΈ
__gnu_pbds::tree< Key, Mapped, Cmp_Fn, Tag, Node_Update, _Alloc > β bestie, this is the tree-based container from libstdc++'s policy-based data structures, and it's lowkey iconic π
(okay and yes, this whole page lives in manual section 3cxx, the C++ library section β noted, moving on π«Ά)
β¨ SYNOPSIS β¨
#include <assoc_container.hpp>
It inherits __gnu_pbds::basic_branch< Key, Mapped, Tag, Node_Update, Policy_Tl, _Alloc >. That's the family tree, fr fr π³
π Public Types
typedef Cmp_Fn cmp_fnβ the comparison functor type. This is the little guy that decides who comes before who β¨typedef Node_Update node_updateβ the node update thingy, straight up π
π Public Member Functions
tree (const cmp_fn &c)β constructor that takes some policy objects.r_cmp_fngets copied by theCmp_Fnobject of the container object, no cap π«tree (const tree &other)β the copy constructor, it exists, that's the vibe π«Άtemplate<typename It > tree (It first, It last)β constructor taking iterators to a range ofvalue_types. Everything betweenfirst_itandlast_itgets inserted into the container object. Slay, range construction πtemplate<typename It > tree (It first, It last, const cmp_fn &c)β same deal but with some policy objects too: thevalue_typesbetweenfirst_itandlast_itget inserted into the container object, andr_cmp_fngets copied by thecmp_fnobject of the container object πtree & operator= (const tree &other)β assignment operator, present and accounted for πvoid swap (tree &other)β swaps with anothertree, that's it, that's the whole function π
π¦ Detailed Description π¦
So the full template situation is literally this:
template<typename Key, typename Mapped, typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag, template< typename Node_CItr, typename
Node_Itr, typename Cmp_Fn_, typename _Alloc_ > class Node_Update =
null_node_update, typename _Alloc = std::allocator<char>>
class __gnu_pbds::tree< Key, Mapped, Cmp_Fn, Tag, Node_Update, _Alloc >
and it's described as "A tree-based container." β short, sweet, main character energy π
π Template Parameters
Keyβ Key type. iykyk πMappedβ Map type.Cmp_Fnβ Comparison functor.Tagβ Instantiating data structure type, seecontainer_tag.Node_Updateβ Updates tree internal-nodes, restores invariants when invalidated. The original literally drops aXXX See design::tree-based-containersnode invariants.here, so consider that note officially passed along, bestie π_Allocβ Allocator type.
The base tag choices are: ov_tree_tag, rb_tree_tag, splay_tree_tag. Pick your fighter β¨
And the base is basic_branch. Periodt.
π Member Typedef Documentation π
π cmp_fn
template<typename Key , typename Mapped , typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag, template< typename Node_CItr, typename
Node_Itr, typename Cmp_Fn_, typename _Alloc_ > class Node_Update =
null_node_update, typename _Alloc = std::allocator<char>>
typedef Cmp_Fn __gnu_pbds::tree< Key, Mapped, Cmp_Fn, Tag, Node_Update, _Alloc
>::cmp_fn
Comparison functor type. That's the entire description and honestly? It ate. π
β Constructor & Destructor Documentation β
π tree (const cmp_fn & c) [inline]
template<typename Key , typename Mapped , typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag, template< typename Node_CItr, typename
Node_Itr, typename Cmp_Fn_, typename _Alloc_ > class Node_Update =
null_node_update, typename _Alloc = std::allocator<char>>
__gnu_pbds::tree< Key, Mapped, Cmp_Fn, Tag, Node_Update, _Alloc >::tree
(const cmp_fn & c) [inline]
Constructor taking some policy objects. r_cmp_fn will be copied by the Cmp_Fn object of the container object. Obsessed with how specific that is π«Ά
π¦ tree (It first, It last) [inline]
template<typename Key , typename Mapped , typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag, template< typename Node_CItr, typename
Node_Itr, typename Cmp_Fn_, typename _Alloc_ > class Node_Update =
null_node_update, typename _Alloc = std::allocator<char>>
template<typename It > __gnu_pbds::tree< Key, Mapped, Cmp_Fn, Tag,
Node_Update, _Alloc >::tree (It first, It last) [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. Give it a range, it fills itself, we love an independent queen π
π tree (It first, It last, const cmp_fn & c) [inline]
template<typename Key , typename Mapped , typename Cmp_Fn = std::less<Key>,
typename Tag = rb_tree_tag, template< typename Node_CItr, typename
Node_Itr, typename Cmp_Fn_, typename _Alloc_ > class Node_Update =
null_node_update, typename _Alloc = std::allocator<char>>
template<typename It > __gnu_pbds::tree< Key, Mapped, Cmp_Fn, Tag,
Node_Update, _Alloc >::tree (It first, It last, const cmp_fn & c)
[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. Range plus policy, the full combo meal π
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. Not a human, just a robot doing its lil thing π€β¨
Heads up bestie: the not-quite-documented ones here βtree (const tree &other),tree & operator= (const tree &other)andvoid swap (tree &other)β come with no description in the original, so I'm not out here inventing lore for them π
And that's the whole page! Signing off from libstdc++, section 3cxx β Doxygen-generated, no date on the tin, still absolutely serving ππβ¨
π¦ where this page comes from
- debian trixie: libstdc++-12-doc 12.4.0-5
- debian trixie: libstdc++-13-doc 13.3.0-16
- debian trixie: libstdc++-14-doc 14.2.0-19
- ubuntu noble: libstdc++-10-doc 10.5.0-4ubuntu2
- ubuntu noble: libstdc++-10-doc 10.5.0-4ubuntu2.1
- ubuntu noble: libstdc++-11-doc 11.4.0-9ubuntu1
- ubuntu noble: libstdc++-11-doc 11.5.0-1ubuntu1~24.04.1
- ubuntu noble: libstdc++-12-doc 12.3.0-17ubuntu1
- ubuntu noble: libstdc++-12-doc 12.4.0-2ubuntu1~24.04.1
- ubuntu noble: libstdc++-13-doc 13.2.0-23ubuntu4
- ubuntu noble: libstdc++-13-doc 13.3.0-6ubuntu2~24.04.1
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- ubuntu noble: libstdc++-14-doc 14.2.0-4ubuntu2~24.04.1
- ubuntu questing: libstdc++-11-doc 11.5.0-7ubuntu1
- ubuntu questing: libstdc++-11-doc 11.5.0-7ubuntu1.1
- ubuntu questing: libstdc++-12-doc 12.5.0-6ubuntu1
- ubuntu questing: libstdc++-13-doc 13.4.0-4ubuntu1
- ubuntu questing: libstdc++-14-doc 14.3.0-8ubuntu1
- ubuntu questing: libstdc++-15-doc 15.2.0-4ubuntu4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms