43# ifndef TPL_BINNODEXT_H
44# define TPL_BINNODEXT_H
81template <
class Node>
inline auto &
COUNT(
Node * p)
noexcept
87 template <
class Node>
static inline
90 assert(r != Node::NullPtr);
113 template <
class Node>
inline
131 template <
class Node>
inline
163 template <
class Node>
inline
184 template <
class Node>
inline
189 parent = Node::NullPtr;
218 template <
class Node,
class Compare>
inline
220 const typename Node::key_type & key,
221 Node *& p, Compare &
cmp)
noexcept
225 if (r == Node::NullPtr)
242template <
class Node,
class Compare = Aleph::less<
typename Node::key_type>>
244 const typename Node::key_type & key,
245 Node *& p, Compare &&
cmp = Compare())
252 template <
class Node,
class Compare>
inline
254 Compare &
cmp)
noexcept
261 template <
class Node,
class Compare = Aleph::less<
typename Node::key_type>>
294 template <
class Node,
297 Node *& p, Compare &
cmp)
noexcept
304 while (r != Node::NullPtr)
310 else if (
cmp(
KEY(r), key))
352 template <
class Node,
class Compare>
inline
357 if (r == Node::NullPtr)
360 Node * q = Node::NullPtr;
364 if (q != Node::NullPtr)
370 if (q != Node::NullPtr)
379 template <
class Node,
397 template <
class Node,
class Compare>
inline
402 if (r == Node::NullPtr)
417 template <
class Node,
438 template <
class Node,
class Compare>
inline
443 if (r == Node::NullPtr)
475 template <
class Node,
class Compare>
static inline
479 if (
root == Node::NullPtr)
481 l = r = Node::NullPtr;
522template <
class Node,
class Compare>
inline
528 root = Node::NullPtr;
543 template <
class Node,
class Compare>
static inline
547 if (
root == Node::NullPtr)
549 l = r = Node::NullPtr;
582 template <
class Node,
class Compare>
inline
587 root = Node::NullPtr;
591 template <
class Node,
615 template <
class Node,
class Compare>
inline
618 if (
root == Node::NullPtr)
625 return Node::NullPtr;
634 template <
class Node,
656 template <
class Node,
class Compare>
inline
659 if (
root == Node::NullPtr)
682 template <
class Node>
static inline
724template <
class Node>
inline
732 r =
tg = Node::NullPtr;
755 template <
class Node>
inline
777 template <
class Node>
inline
780 if (
ts == Node::NullPtr)
783 if (
tg == Node::NullPtr)
794 ts =
tg = Node::NullPtr;
815 template <
class Node,
818 Compare &
cmp)
noexcept
820 if (
root == Node::NullPtr)
821 return Node::NullPtr;
850template <
class Node,
class Compare = Aleph::less<
typename Node::key_type>>
852 const typename Node::key_type & key,
859 template <
class Node>
static inline
894 template <
class Node>
inline
906 template <
class Node>
inline
909 if (
root == Node::NullPtr)
924 template <
class Node>
inline
927 assert(p != Node::NullPtr);
945 template <
class Node>
inline
948 assert(p != Node::NullPtr);
971 template <
class Node,
class Key,
class Compare>
inline
975 if (
root == Node::NullPtr)
1009template <
class Node,
class Key,
1036template <
class TreeType,
class Node,
typename Key,
class Compare>
1063 return curr !=
nullptr;
1142 std::pair<long, Node*> p =
tree_ptr->find_position(key);
1177 <<
"Iterator has no current";
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_range_error_if(C)
Throws std::range_error if condition holds.
SentinelCtor
Tag type for sentinel node construction.
void put_itor_at_the_end(Itor &it) noexcept
WeightedDigraph::Node Node
BinNodeXt_Data(SentinelCtor) noexcept
size_t size() const noexcept
BinNodeXt_Data() noexcept
size_t & getCount() noexcept
Node for extended binary search tree.
Base iterator template for ranked binary search trees.
BinTreeXt_Iterator() noexcept
void reset_last() noexcept
static constexpr int Pos_Empty_Container
bool has_curr() const noexcept
void reset_first() noexcept
bool operator==(const BinTreeXt_Iterator &itor) const noexcept
void update_curr() const noexcept
void update_pos() const noexcept
Node * get_curr_ne() const noexcept
BinTreeXt_Iterator(const TreeType &__tree, Node *__curr) noexcept
bool curr_updated() const noexcept
void reset_to_node(Node *node) noexcept
static constexpr int Pos_Not_Current
BinTreeXt_Iterator(const TreeType &__tree, const size_t pos) noexcept
BinTreeXt_Iterator & operator=(const BinTreeXt_Iterator &itor) noexcept
void reset_to_pos(const size_t pos) noexcept
bool is_container_empty() const noexcept
size_t get_current_position() const
static constexpr int Pos_Not_Updated
BinTreeXt_Iterator(const BinTreeXt_Iterator &itor) noexcept
bool pos_updated() const noexcept
void reset_to_key(const Key &key) noexcept
BinTreeXt_Iterator(const TreeType &__tree) noexcept
bool operator!=(const BinTreeXt_Iterator &itor) const
Node * get_curr() const noexcept
T remove()
Remove the first item of the list.
__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)
long inorder_position(Node *r, const typename Node::key_type &key, Node *&p, Compare &cmp) noexcept
Compute the inorder position of a key.
Node * insert_dup_by_key_xt(Node *&r, Node *p, Compare &cmp) noexcept
Insert a node in an extended binary search tree without testing for duplicity.
Node * insert_dup_root_xt(Node *&root, Node *p, Compare &cmp) noexcept
Insert a node as root of an extended binary search tree.
Node * insert_by_key_xt(Node *&r, Node *p, Compare &cmp) noexcept
Insert a node in an extended binary search tree.
bool check_rank_tree(Node *root) noexcept
Return true if root is a valid extended binary tree.
void split_pos_rec(Node *&r, const size_t i, Node *&ts, Node *&tg)
Split a extended binary tree according to a position.
#define DECLARE_BINNODE_SENTINEL(Name, height, Control_Data)
Specify tree node for a binary tree.
constexpr Node *& RLINK(Node *p) noexcept
Return the right tree of p.
auto & COUNT(Node *p) noexcept
Return the number of nodes of the tree fron p is root.
Node * remove_by_pos_xt(Node *&root, size_t pos)
Remove from a extended binary tree the node whose inorder position is pos.
Node * remove_by_key_xt(Node *&root, const typename Node::key_type &key, Compare &cmp) noexcept
Remove a key of extended binary tree.
Node * insert_root_xt(Node *&root, Node *p, Compare &cmp) noexcept
Insert a node p as root of an extended binary search tree.
Node * rotate_to_left_xt(Node *p) noexcept
Rotate to left the extended binary tree with root p.
bool split_key_rec_xt(Node *&root, const typename Node::key_type &key, Node *&l, Node *&r, Compare &cmp) noexcept
Split an extended binary search tree according to a key.
Node * select(Node *r, const size_t pos)
Iterative selection of a node according to inorder position.
Node * select_ne(Node *r, const size_t pos) noexcept
Iterative selection of a node according to inorder position without exception.
constexpr Node *& LLINK(Node *p) noexcept
Return a pointer to left subtree.
Node * rotate_to_right_xt(Node *p) noexcept
Rotate to right the extended bianry tree with root p
void split_key_dup_rec_xt(Node *&root, const typename Node::key_type &key, Node *&l, Node *&r, Compare &cmp) noexcept
Split an extended binary search tree according to a key which can be in the tree.
void insert_by_pos_xt(Node *&r, Node *p, size_t pos)
Insert a node in a specific inorder position in a binary tree.
Node * select_rec(Node *r, const size_t i)
Recursively select the i-th node inorder sense.
Node * join_exclusive_xt(Node *&ts, Node *&tg) noexcept
Exclusive union of two extended binary search trees.
const long double offset[]
Offset values indexed by symbol string length (bounded by MAX_OFFSET_INDEX)
Main namespace for Aleph-w library functions.
static Node * __remove_by_pos_xt(Node *&root, size_t pos) noexcept
Node * search_or_insert_root_rec_xt(Node *root, Node *p, Compare &cmp) noexcept
Search or insert a key in an extended binary search tree.
static void __split_key_dup_rec_xt(Node *root, const typename Node::key_type &key, Node *&l, Node *&r, Compare &cmp) noexcept
static Node * __select_rec(Node *r, const size_t i) noexcept
static bool __split_key_rec_xt(Node *root, const typename Node::key_type &key, Node *&l, Node *&r, Compare &cmp) noexcept
long find_position(Node *r, const typename Node::key_type &key, Node *&p, Compare &cmp) noexcept
Find the inorder position of a key in an extended binary search tree.
static void __split_pos_rec(Node *r, size_t i, Node *&ts, Node *&tg) noexcept
Node * search_or_insert_by_key_xt(Node *&r, Node *p, Compare &cmp) noexcept
Search or insert a node in an extended binary search tree.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Utility functions for binary tree operations.
Basic binary tree node definitions.