42#ifndef TPL_BINNODEUTILS_H
43#define TPL_BINNODEUTILS_H
74template <BinNodeLike Node>
78 "nullptr is not an empty tree for a node type with a sentinel; use Node::NullPtr");
80template <BinNodeLike Node>
84 if (node == Node::NullPtr)
89 (*visitFct)(node, level, position);
117template <BinNodeLike Node>
126template <BinNodeLike Node>
130 if (p == Node::NullPtr)
133 (*visitFct)(p, level, position);
162template <BinNodeLike Node>
171template <BinNodeLike Node>
175 if (node == Node::NullPtr)
181 (*visitFct)(node, level, position);
207template <BinNodeLike Node>
237 if (
root == Node::NullPtr)
274template <BinNodeLike Node,
class Op>
302 if (
root == Node::NullPtr)
339template <BinNodeLike Node,
class Op>
366 if (
root == Node::NullPtr)
403template <BinNodeLike Node,
class Op>
409template <BinNodeLike Node>
412 if (
root == Node::NullPtr)
420template <BinNodeLike Node>
423 if (
root == Node::NullPtr)
431template <BinNodeLike Node>
434 if (
root == Node::NullPtr)
449template <BinNodeLike Node>
464template <BinNodeLike Node>
479template <BinNodeLike Node>
493template <BinNodeLike Node>
497 if (
root == Node::NullPtr)
504template <BinNodeLike Node>
516template <BinNodeLike Node>
520 if (
root == Node::NullPtr)
537template <BinNodeLike Node>
541 if (
root == Node::NullPtr)
547 root = Node::NullPtr;
562template <BinNodeLike Node>
566 if (
root == Node::NullPtr)
569 using Key =
typename Node::key_type;
573 root->get_key().~Key();
574 root = Node::NullPtr;
584template <BinNodeLike Node>
588 if (
root == Node::NullPtr)
589 return Node::NullPtr;
623template <BinNodeLike Node>
630 if (
t1 == Node::NullPtr
or t2 == Node::NullPtr)
647template <BinNodeLike Node,
class Equal>
653 if (
t1 == Node::NullPtr
or t2 == Node::NullPtr)
663template <BinNodeLike Node,
class Equal = std::equal_to<
typename Node::key_type>>
685template <BinNodeLike Node>
689 if (
root == Node::NullPtr)
693 queue.
put(std::pair<Node *, bool>(
root,
bool()));
697 std::pair<Node *, bool>
pr = queue.
get();
700 (*visitFct)(p, pos,
pr.second);
702 if (
LLINK(p) != Node::NullPtr)
703 queue.
put(std::pair<Node *, bool>(
LLINK(p),
true));
705 if (
RLINK(p) != Node::NullPtr)
706 queue.
put(std::pair<Node *, bool>(
RLINK(p),
false));
725template <BinNodeLike Node,
class Operation>
728 if (
root == Node::NullPtr)
739 if (
LLINK(p) != Node::NullPtr)
742 if (
RLINK(p) != Node::NullPtr)
748template <BinNodeLike Node,
class Operation>
769template <
template <
class>
class Node,
typename Key>
789 for (
int j =
l_i; j <=
r_i; ++j)
797 ah_domain_error_if(i < 0) <<
"build_tree: root key not found in inorder array (corrupted input)";
806template <
template <
class>
class Node,
typename Key>
824 <<
"build_postorder: root key not found in inorder array (corrupted input)";
833template <BinNodeLike Node>
837 if (
root == Node::NullPtr)
840 if (current_level == level)
858template <BinNodeLike Node>
886template <BinNodeLike Node>
889 if (
root == Node::NullPtr)
893 while (p != Node::NullPtr)
896 if (q == Node::NullPtr)
905 while (q !=
r and RLINK(q) != Node::NullPtr)
917 RLINK(q) = Node::NullPtr;
943template <BinNodeLike Node>
946 if (node == Node::NullPtr)
949 Node *p = node, *
r = Node::NullPtr;
950 while (p != Node::NullPtr)
954 if (q == Node::NullPtr)
963 while (q !=
r and RLINK(q) != Node::NullPtr)
974 RLINK(q) = Node::NullPtr;
980template <BinNodeLike Node>
983 if (p == Node::NullPtr)
997template <BinNodeLike Node>
1017template <BinNodeLike Node>
1020 if (
root == Node::NullPtr)
1044template <BinNodeLike Node>
1059template <BinNodeLike Node>
1063 const size_t n = bits.
size();
1066 for (
size_t i = 0; i < n; ++i)
1067 str.push_back(bits(i) ?
'b' :
'a');
1072template <BinNodeLike Node>
1077 <<
"bits_to_tree_helper: bit array index out of bounds (malformed input)";
1079 if (
const int bit = array.
read_bit(i++); bit == 1)
1080 return Node::NullPtr;
1083 Node *left = Node::NullPtr;
1084 Node *right = Node::NullPtr;
1117template <BinNodeLike Node>
1140template <BinNodeLike Node>
1143 if (
root == Node::NullPtr)
1162template <BinNodeLike Node>
1165 if (
root == Node::NullPtr)
1189template <BinNodeLike Node>
1209template <BinNodeLike Node>
1227template <BinNodeLike Node,
class Get_Key>
1230 if (
root == Node::NullPtr)
1233 const std::string str = Get_Key()(
root);
1235 for (
const char ch : str)
1262template <BinNodeLike Node,
class Load_Key>
1265 if (
root == Node::NullPtr)
1303template <BinNodeLike Node,
class Get_Key>
1312 output <<
"nullptr };" <<
'\n';
1344template <BinNodeLike Node,
class Load_Key>
1356template <BinNodeLike Node,
class Compare>
1358 const typename Node::key_type *max_key,
const Compare &
cmp)
1360 if (p == Node::NullPtr)
1363 const auto &key =
KEY(p);
1382template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1400template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1402 const Compare &
cmp = Compare())
1405 return Node::NullPtr;
1441template <
typename T,
class Compare = Aleph::less<T>>
1465template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1472 while (
root != Node::NullPtr)
1490 return Node::NullPtr;
1501template <BinNodeLike Node>
1505 assert(
root != Node::NullPtr &&
"find_min called on empty tree");
1520template <BinNodeLike Node>
1524 assert(
root != Node::NullPtr &&
"find_max called on empty tree");
1539template <BinNodeLike Node>
1542 assert(p != Node::NullPtr);
1547 while (
LLINK(p) != Node::NullPtr)
1564template <BinNodeLike Node>
1567 assert(p != Node::NullPtr);
1573 while (
RLINK(p) != Node::NullPtr)
1594template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1644template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1682template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1689 const auto &
pk =
KEY(p);
1712template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1719 const auto &
pk =
KEY(p);
1742template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1749 const auto &
pk =
KEY(p);
1760template <BinNodeLike Node,
class Compare>
1764 if (
root == Node::NullPtr)
1766 ts =
tg = Node::NullPtr;
1809template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1816 root = Node::NullPtr;
1820template <BinNodeLike Node,
class Compare>
1824 if (
root == Node::NullPtr)
1826 ts =
tg = Node::NullPtr;
1856template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1862 root = Node::NullPtr;
1878template <BinNodeLike Node>
1881 if (
ts == Node::NullPtr)
1884 if (
tg == Node::NullPtr)
1891 ts =
tg = Node::NullPtr;
1907template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1912 if (
root == Node::NullPtr)
1913 return Node::NullPtr;
1942template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1946 Node *
l = Node::NullPtr, *
r = Node::NullPtr;
1949 return Node::NullPtr;
1968template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1989template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
1992 if (
t2 == Node::NullPtr)
2023template <BinNodeLike Node,
class Compare = Aleph::less<
typename Node::key_type>>
2026 if (
t1 == Node::NullPtr)
2029 if (
t2 == Node::NullPtr)
2041 assert(p != Node::NullPtr);
2057template <BinNodeLike Node>
2060 assert(p != Node::NullPtr);
2076template <BinNodeLike Node>
2079 assert(p != Node::NullPtr);
2100template <BinNodeLike Node>
2103 assert(p != Node::NullPtr);
2118template <BinNodeLike Node>
2121 assert(p != Node::NullPtr);
2152template <BinNodeLike Node,
class Key,
class Compare = Aleph::less<
typename Node::key_type>>
2157 assert(
l == Node::NullPtr
and r == Node::NullPtr);
2158 if (
root == Node::NullPtr)
2160 l =
r = Node::NullPtr;
2180 while (current != Node::NullPtr)
2182 if (
cmp(key,
KEY(current)))
2205 root = Node::NullPtr;
2217template <BinNodeLike Node>
2224 assert(p != Node::NullPtr
and q != Node::NullPtr
and pp != Node::NullPtr
and pq != Node::NullPtr);
2236 LLINK(p) = Node::NullPtr;
2269template <BinNodeLike Node>
2276 assert((p != Node::NullPtr)
and (q != Node::NullPtr)
and (
pp != Node::NullPtr)
and
2277 (
pq != Node::NullPtr));
2289 RLINK(p) = Node::NullPtr;
2325template <BinNodeLike
Node,
class Key =
typename Node::key_type,
2330 if (
root == Node::NullPtr)
2337 return Node::NullPtr;
2346 return Node::NullPtr;
2352 return Node::NullPtr;
2367template <BinNodeLike
Node,
class Key =
typename Node::key_type,
2372 if (
root == Node::NullPtr)
2410template <
class Node>
2421 std::swap(
root, it.root);
2422 std::swap(
curr, it.curr);
2456 if (
RLINK(p) != Node::NullPtr)
2459 if (
LLINK(p) != Node::NullPtr)
2470 if (
root == Node::NullPtr)
2472 curr = Node::NullPtr;
2482 curr = Node::NullPtr;
2506 return curr != Node::NullPtr;
2527 if (
l != Node::NullPtr)
2530 if (
r != Node::NullPtr)
2535 if (
r != Node::NullPtr)
2542 curr = Node::NullPtr;
2578template <BinNodeLike Node,
class Op>
2582 if (
not op(it.get_curr()))
2605template <BinNodeLike Node,
class Op>
2619template <
class Node>
2629 while (
LLINK(
r) != Node::NullPtr)
2639 while (
RLINK(
r) != Node::NullPtr)
2647 if (
root != Node::NullPtr)
2666 std::swap(
root, it.root);
2667 std::swap(
curr, it.curr);
2668 std::swap(
pos, it.pos);
2702 if (
root == Node::NullPtr)
2704 curr = Node::NullPtr;
2716 curr = Node::NullPtr;
2741 return curr != Node::NullPtr;
2772 if (
curr != Node::NullPtr)
2779 curr = Node::NullPtr;
2816template <BinNodeLike Node,
class Op>
2820 if (
not op(it.get_curr()))
2829template <BinNodeLike Node,
class Op>
2853template <BinNodeLike Node,
class Op>
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
Exception handling system with formatted messages for Aleph-w.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
Standard functor implementations and comparison objects.
WeightedDigraph::Node Node
Space-efficient bit array implementation.
EepicNode< long > * build_tree()
size_t size_t int32_t * out
Stack implemented with simple dynamic array and with bounds verification.
void swap(ArrayStack &s) noexcept
Swap this with s
void empty() noexcept
Empty the stack.
bool is_empty() const noexcept
Return true if stack is empty.
T pop()
Extract the last more recently inserted element.
T & push(const T &data)
Push into stack a copy of data
Inorder iterator on the nodes of a binary tree.
BinNodeInfixIterator()=default
Node * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
void next()
Move the iterator one position forward.
void reset_last() noexcept
Reset the iterator to the last node inorder.
Node * get_curr() const
Return the current node. Throw overflow_error if there is no current.
BinNodeInfixIterator(const BinNodeInfixIterator &it)
bool is_last() const noexcept
bool has_curr() const noexcept
Return true the iterator has current node.
BinNodeInfixIterator(Node *r) noexcept
Initialize an iterator on the first node inorder.
bool is_in_first() const noexcept
Return true if the iterator is on the first node.
BinNodeInfixIterator(BinNodeInfixIterator &&it) noexcept
BinNodeInfixIterator & operator=(const BinNodeInfixIterator &it)
Node * advance_to_min(Node *r) noexcept
static Node * advance_to_max(Node *r) noexcept
size_t get_pos() const
Return the current position of iterator. Only valid if has_curr() == true.
void swap(BinNodeInfixIterator &it) noexcept
void reset_first() noexcept
Reset the iterator to the first node inorder.
Preorder iterator on the nodes of a binary tree.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
Node * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
bool has_curr() const noexcept
Return true if iterator has current node.
BinNodePrefixIterator(BinNodePrefixIterator &&it) noexcept
Node * get_curr() const
Return a pointer to current node.
void reset_first() noexcept
Reset the iterator to the first node in preorder sense.
void reset_last() noexcept
Reset the iterator to the last node in preorder.
BinNodePrefixIterator(Node *r) noexcept
Initialize an iterator on the first node in preorder for the tree with root r
void next()
Move the iterator one position forward.
void swap(BinNodePrefixIterator &it) noexcept
Swap thiswith it
BinNodePrefixIterator & operator=(const BinNodePrefixIterator &it)
void end() noexcept
Put the iterator in end state.
BinNodePrefixIterator()=default
BinNodePrefixIterator(const BinNodePrefixIterator &it)
static Node * last(Node *p) noexcept
Contiguous array of bits.
int read_bit(const size_t i) const
Read bit i.
void load_from_array_of_chars(const unsigned char str[], const size_t num_bits)
Reads an array of bits saved in a character array.
void load(std::istream &input)
Loads an array of bits from a file.
void push(const unsigned int value)
Inserts the value at the end of the array.
constexpr size_t size() const noexcept
Returns the dimension of the bit array.
Dynamic doubly linked list with O(1) size and bidirectional access.
Dynamic queue of elements of generic type T based on single linked list.
T & put(const T &data)
The type of element.
T get()
Remove the oldest item of the queue.
bool is_empty() const noexcept
Return true if this is empty.
Doubly-linked list (defined in tpl_dynList.H).
Generic inorder traversal of a binary tree.
void traverse(Node *root, Op &&op) const
Invoke to traversal from root node.
static void for_each_inorder(Node *root, Op &&op)
void operator()(Node *root, Op &op) const
Generic postorder traversal of a binary tree.
void operator()(Node *root, Op &op) const
static void postorder(Node *root, Op &&op)
void traverse(Node *root, Op &&op) const
Invoke the traversal.
Generic preorder traversal of a binary tree.
static void preorder(Node *root, Op &&op)
void traverse(Node *root, Op &&op) const
Invoke the traversal.
void operator()(Node *root, Op &op) const
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
bool prefix_traverse(Node *root, Op op)
Traverse a tree in preorder via its iterator and performs a conditioned operation on each item.
int postOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in postorder a binary tree.
size_t compute_cardinality_rec(Node *root) noexcept
Count the number of nodes of a binary tree.
Node * rotate_to_left(Node *p) noexcept
Rotate to the left the tree with root p
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
void save_tree_in_array_of_chars(Node *root, const std::string &array_name, std::ostream &output)
Generate C++ array declarations for a binary tree.
Node * search_rank_parent(Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept
Rank search of a key in a binary search tree.
void save_tree_keys_in_prefix(Node *root, std::ostream &output)
Store in output stream the tree keys in preorder.
void load_tree_keys_in_prefix(Node *root, std::istream &input)
Load the keys stored in preorder from an input stream.
bool level_traverse(Node *root, Operation &operation)
Level traverse a tree and execute an operation.
DynDlist< Node * > compute_nodes_in_level(Node *root, const int &level)
Count the number of nodes in a specific tree level.
Node * join_preorder(Node *t1, Node *t2, Node *&dup, const Compare &cmp=Compare()) noexcept
Union of two binary search trees.
void swap_node_with_successor(Node *p, Node *&pp, Node *q, Node *&pq) noexcept
Swap a node with its successor inorder.
Node * remove_from_bst(Node *&root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept
Remove a key from a binary search tree.
void for_each_in_order(Node *root, Op &&op)
Execute an operation in order sense for each node of tree.
Node * find_predecessor(Node *p, Node *&pp) noexcept
Find the inorder predecessor of p
Node * load_tree_from_array(const unsigned char bits[], const size_t &num_bits, const char *keys[])
Build a binary tree from two arrays.
Node * search_parent(Node *root, const typename Node::key_type &key, Node *&parent, const Compare &cmp=Compare()) noexcept
Search a key and find its node and parent.
Node * find_min(Node *root) noexcept
Return the minimum key contained in a binary search tree.
Node * rotate_to_right(Node *p) noexcept
Rotate to the right the tree with root p
bool split_key_rec(Node *&root, const typename Node::key_type &key, Node *&ts, Node *&tg, const Compare &cmp=Compare()) noexcept
Split recursively according to a key.
Node * find_successor(Node *p, Node *&pp) noexcept
Find the inorder successor of p
Node * copyRec(Node *root)
Copy recursively a tree.
void for_each_postorder(Node *root, Op &&op)
Execute an operation in postorder sense for each node of tree.
Node * load_tree(std::istream &input)
Load and build a binary tree from a stream.
void for_each_preorder(Node *root, Op &&op)
Execute an operation in preorder sense for each node of tree.
Node * search_or_insert_in_bst(Node *&r, Node *p, const Compare &cmp=Compare()) noexcept
Search or insert a node in a binary search tree.
void save_tree(Node *root, std::ostream &output)
Store a binary tree in a stream.
void split_key_dup_rec(Node *&root, const typename Node::key_type &key, Node *&ts, Node *&tg, const Compare &cmp=Compare()) noexcept
Split a tree according to a key value.
ThreeWayCmp three_way_compare(const T &a, const T &b, const Compare &cmp=Compare()) noexcept
Three-way comparison using a binary comparator.
bool check_bst(Node *p, const Compare &cmp=Compare())
Return true if p is a binary search tree.
Node * bits_to_tree(const BitArray &array, int idx=0)
Build a binary tree given its bits code.
Node * insert_in_bst(Node *&r, Node *p, const Compare &cmp=Compare()) noexcept
Insert a node p in a binary search tree.
void tree_to_bits(Node *root, BitArray &array)
Compute a bit code for the binary tree.
size_t internal_path_length(Node *p) noexcept
Compute the internal path length.
void preOrderThreaded(Node *node, void(*visitFct)(Node *))
Traverse preorder a binary tree without recursion and without stack.
void inOrderThreaded(Node *root, void(*visitFct)(Node *))
Traverse inorder a binary tree without recursion and without stack.
Node * preorder_to_bst(DynArray< typename Node::key_type > &preorder, int l, int r, const Compare &cmp=Compare())
Build a binary search tree from its preorder traversal.
void levelOrder(Node *root, void(*visitFct)(Node *, int, bool))
Traverse a binary tree by levels.
int inOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively inorder a binary tree.
Node * join_exclusive(Node *&ts, Node *&tg) noexcept
Exclusive join of two binary trees.
void destroyRec(Node *&root) noexcept
Free recursively all the memory occupied by the tree root
Node * searchInBinTree(Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept
Search a key in a binary search tree.
Node * search_or_insert_root_rec(Node *root, Node *p, const Compare &cmp=Compare()) noexcept
Search and eventually insert p as root in a binary search tree.
Node * insert_dup_in_bst(Node *&root, Node *p, const Compare &cmp=Compare()) noexcept
Insert a node p in a binary search tree.
Node * insert_root(Node *&root, Node *p, const Compare &cmp=Compare()) noexcept
Insert the node p as root of a binary search tree.
Node * insert_dup_root(Node *&root, Node *p, const Compare &cmp=Compare()) noexcept
Insert node p as root of a binary search tree.
void swap_node_with_predecessor(Node *p, Node *&pp, Node *q, Node *&pq) noexcept
Swap a node with its predecessor inorder.
Node * insert_root_rec(Node *root, Node *p, const Compare &cmp=Compare()) noexcept
Insert a node as root in a binary search tree.
void assert_valid_tree_root(const Node *root) noexcept
Debug-only check that root is a valid tree for Node.
bool infix_traverse(Node *root, Op op)
Traverse a tree in inorder via its iterator and performs a conditioned operation on each item.
size_t computeHeightRec(Node *root) noexcept
Compute recursively the height of root
Node * find_max(Node *root) noexcept
Return the maximum key contained in a binary search tree.
void split_key(Node *&root, const Key &key, Node *&l, Node *&r, const Compare &cmp=Compare()) noexcept
Split a binary search tree according to a key.
Main namespace for Aleph-w library functions.
size_t size(Node *root) noexcept
static void infix(Node *root, DynList< Node * > &acc)
bool traverse(Node *root, Op op)
static void suffix(Node *root, DynList< Node * > &acc)
void infix_for_each(Node *root, Op op)
Traverse all the container and performs an operation on each element.
void inorder_rec_helper(Node *node, const int &level, int &position, void(*visitFct)(Node *, int, int))
void load_tree_keys_from_array(Node *root, const char *keys[], int &idx)
and
Check uniqueness with explicit hash + equality functors.
std::decay_t< typename HeadC::Item_Type > T
std::string code(Node *root)
Compute a string with the Lukasiewicz`s word of a tree.
void preorder_rec_helper(Node *p, const int &level, int &position, void(*visitFct)(Node *, int, int))
static void prefix(Node *root, DynList< Node * > &acc)
bool split_key_rec_helper(Node *root, const typename Node::key_type &key, Node *&ts, Node *&tg, Compare &cmp) noexcept
void postorder_rec_helper(Node *node, const int &level, int &position, void(*visitFct)(Node *, int, int))
bool less_or_equal_than(const T &op1, const T &op2, Compare &cmp)
Determines if op1 is less than or equal to op2 using a comparison operator.
void put_tree_keys_in_array(Node *root, std::ostream &out)
Node< Key > * build_postorder(const DynArray< Key > &post, long lp, long rp, const DynArray< Key > &in, long li, long ri)
ThreeWayCmp
Constants for three-way comparison results.
@ CmpGreater
First argument is greater than second.
@ CmpLess
First argument is less than second.
@ CmpEqual
Arguments are equal.
bool areEquivalents(Node *t1, Node *t2, Equal &op) noexcept
Return true if trees are equivalents.
Node * bits_to_tree_helper(const BitArray &array, int &i)
std::ostream & join(const C &c, const std::string &sep, std::ostream &out)
Join elements of an Aleph-style container into a stream.
size_t internal_path_length_helper(Node *p, const size_t &level) noexcept
void split_key_dup_rec_helper(Node *root, const typename Node::key_type &key, Node *&ts, Node *&tg, Compare &cmp) noexcept
bool areSimilar(Node *t1, Node *t2) noexcept
Return true if both trees are similar.
bool check_bst_range(Node *p, const typename Node::key_type *min_key, const typename Node::key_type *max_key, const Compare &cmp)
void compute_nodes_in_level_helper(Node *root, long level, const long current_level, DynDlist< Node * > &level_list)
void callKeyDestructorsRec(Node *&root) noexcept
Traverses recursively the tree and calls key's destructors.
void prefix_for_each(Node *root, Op op)
Traverse in preorder all the container and performs an operation on each element.
DynArray< int > postorder
Circular queue implementations backed by arrays.
Stack implementations backed by dynamic or fixed arrays.
Basic binary tree node definitions.
Dynamic doubly linked list implementation.
Dynamic queue implementation based on linked lists.