__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_fn gets copied by the Cmp_Fn object 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 of value_types. Everything between first_it and last_it gets 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: the value_types between first_it and last_it get inserted into the container object, and r_cmp_fn gets copied by the cmp_fn object of the container object πŸ’–
  • tree & operator= (const tree &other) β€” assignment operator, present and accounted for πŸ‘‘
  • void swap (tree &other) β€” swaps with another tree, 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, see container_tag.
  • Node_Update β€” Updates tree internal-nodes, restores invariants when invalidated. The original literally drops a XXX 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) and void 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 πŸŽ€πŸ’–βœ¨