135 template <
template <
typename>
class NodeType,
typename Key,
class Compare>
150 template <
class Inserter>
153 auto rec = [&] (
auto && self,
Node * n)
noexcept ->
void
155 if (n == Node::NullPtr)
180 std::swap(
root, tree.root);
181 std::swap(
cmp, tree.cmp);
320 if (op.insert(root, n) == Node::NullPtr)
321 op.insert(dup.root, n);
336 move_all(t.root, [&] (
Node * n)
noexcept { op.insert_dup(root, n); });
353 t.root = Node::NullPtr;
378 template <
typename Key,
class Compare = Aleph::less<Key>>
393 template <
typename Key,
class Compare = Aleph::less<Key>>
C++20 concepts for constraining comparison functors.
Inorder iterator on the nodes of a binary tree.
Simple (unbalanced) binary search tree.
GenBinTree & operator=(const GenBinTree &)=delete
static void move_all(Node *&src, Inserter inserter) noexcept
void join_dup(GenBinTree &t) noexcept
Join this with t independently of the presence of duplicated keys.
GenBinTree(const GenBinTree &)=delete
Node * getRoot() const noexcept
Return the root of tree.
Node *& getRoot() noexcept
Return the root of tree.
bool split(const Key &key, GenBinTree &l, GenBinTree &r) noexcept
Split the tree according to a key.
bool verify() const
Return true if the tree is a consistent (correct) binary search tree.
Node * insert(Node *p) noexcept
Insert a node in the tree.
Compare & key_comp() noexcept
return the comparison criteria
void split_dup(const Key &key, GenBinTree &l, GenBinTree &r) noexcept
Split the tree according to a key that could be in the tree.
Node * search(const Key &key) const noexcept
Search a key.
GenBinTree(Compare _cmp=Compare()) noexcept
Initialize an empty tree with comparison criteria __cmp
void join(GenBinTree &tree, GenBinTree &dup) noexcept
Join tree with this.
Compare & get_compare() noexcept
Node * insert_dup(Node *p) noexcept
Insert a node in the tree.
Node * remove(const Key &key) noexcept
Remove a key from the tree.
void join_exclusive(GenBinTree &t) noexcept
Join exclusive of this with t
void swap(GenBinTree &tree) noexcept
Swap this with tree in constant time.
virtual ~GenBinTree()=default
Node * search_or_insert(Node *p) noexcept
Search or insert a key.
Strict weak ordering constraint for BST comparators.
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.
Main namespace for Aleph-w library functions.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Binary search tree with nodes with virtual destructors,.
Binary search tree with nodes without virtual destructors,.
Iterator on nodes of the tree.
Iterator() noexcept=default
Default constructor creates an "end" iterator.
Iterator(const GenBinTree &tree)
Binary tree operations (split, join, rotate).