JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::avl::avl_node< K, V > Struct Template Reference

Node element for the contiguous AVL tree. More...

#include <jh/core/ordered_map.h>

Public Types

using key_type = K
 Key type stored by this node.
using value_type = V
 Mapped value type stored by this node.
using store_t = std::pair<K, V>
 Internal storage type (key/value pair).

Public Member Functions

const key_typekey () const
 Returns key (const reference).
value_typevalue ()
 Returns mapped value (reference).
store_tstored ()
 Returns full stored pair (reference).
const store_tstored () const
 Returns full stored pair (const reference).
 avl_node ()
 Default constructor (value-initializes storage and clears links).
template<typename KK, typename VV>
 avl_node (KK &&k, VV &&v, std::size_t parent_index=static_cast< std::size_t >(-1), std::size_t left_index=static_cast< std::size_t >(-1), std::size_t right_index=static_cast< std::size_t >(-1), std::uint16_t h=1)
 Construct a node by forwarding a key and a mapped value.
 avl_node (const avl_node &)=default
 Copy constructor.
avl_nodeoperator= (const avl_node &)=default
 Copy assignment.
 avl_node (avl_node &&)=default
 Move constructor.
avl_nodeoperator= (avl_node &&)=default
 Move assignment.
 ~avl_node ()=default
 Destructor.

Public Attributes

store_t stored_
 Container for the key/value payload.
std::size_t parent
 Index of parent node, or -1 for root.
std::size_t left
 Index of left child, or -1 if none.
std::size_t right
 Index of right child, or -1 if none.
std::uint16_t height
 Height of this node in the AVL tree.

Detailed Description

template<typename K, typename V>
requires ((requires(const K &a, const K &b) { { a < b } -> std::convertible_to<bool>; }) && std::copy_constructible<K> && std::copy_constructible<V>)
struct jh::avl::avl_node< K, V >

Node element for the contiguous AVL tree.

Template Parameters
Kkey type (strictly ordered)
Vmapped value type

Represents a single AVL node stored inside a contiguous vector. Links are expressed as indices rather than pointers. Each node contains a key-value pair, parent/left/right indices, and an explicit height field used for balancing. No per-node allocation occurs; nodes are relocated only during erase compactification.

Constructor & Destructor Documentation

◆ avl_node()

template<typename K, typename V>
template<typename KK, typename VV>
jh::avl::avl_node< K, V >::avl_node ( KK && k,
VV && v,
std::size_t parent_index = static_cast<std::size_t>(-1),
std::size_t left_index = static_cast<std::size_t>(-1),
std::size_t right_index = static_cast<std::size_t>(-1),
std::uint16_t h = 1 )
inline

Construct a node by forwarding a key and a mapped value.

Template Parameters
KKA cv/ref-qualified form of K.
VVA cv/ref-qualified form of V.
Parameters
kKey forwarded into the stored key.
vMapped value forwarded into the stored value.
parent_indexParent index of this node.
left_indexLeft-child index of this node.
right_indexRight-child index of this node.
hInitial height of the node.

The documentation for this struct was generated from the following file: