105 template <
template <
typename>
class NodeType,
typename Key,
class Compare>
139 if (p != Node::NullPtr) [[
likely]]
149 if (p != Node::NullPtr) [[
likely]]
153 while (p != Node::NullPtr);
183 if (p != Node::NullPtr) [[
likely]]
191 if (p != Node::NullPtr) [[
likely]]
195 while (p != Node::NullPtr);
261 else if (
DIFF(r) == -1)
298 else if (
DIFF(r) == -1)
413 while (
LLINK(succ) != Node::NullPtr)
430 LLINK(p) = Node::NullPtr;
431 if (
RLINK(p) == succ)
499 std::swap(
root, tree.root);
500 std::swap(
cmp, tree.cmp);
531 if (
root == Node::NullPtr)
568 if (
root == Node::NullPtr)
591 if (
root == Node::NullPtr)
610 if (
root == Node::NullPtr)
626 if (
LLINK(p) == Node::NullPtr)
635 if (
RLINK(p) == Node::NullPtr)
702 template <
typename Key,
class Compare = Aleph::less<Key>>
724 template <
typename Key,
class Compare = Aleph::less<Key>>
#define AH_ERROR(format, args...)
Print an error message (always enabled).
Standard functor implementations and comparison objects.
AVL tree node with balance factor.
bool is_avl(Node *p)
Validate that a tree satisfies AVL properties.
#define DIFF(p)
Access the balance factor of node p.
Inorder iterator on the nodes of a binary tree.
T & push(const T &data) noexcept
Push a copy of data
size_t size() const noexcept
Return the number of elements stored in the stack.
T popn(const int &n) noexcept
Perform in constant time n pops.
T & top() const noexcept
Return a modifiable referemce to stack's top.
T pop() noexcept
Pop by moving the top of stack.
AVL balanced binary search tree.
Node * search(const Key &key) const noexcept
Search a node containing key; if found, then a pointer to the node containing it is returned; otherwi...
static Node * restore_avl(Node *p, Node *pp) noexcept
void restore_avl_after_insertion(Node *p) noexcept
void swap(Gen_Avl_Tree &tree) noexcept
Swap in constant time all the items of this with the items of tree.
Node * search_or_insert(Node *p) noexcept
Search or insert a key.
constexpr Compare & get_compare() noexcept
Node * insert_dup(Node *p) noexcept
Insert the node p without testing for key duplicity.
constexpr Node *& getRoot() noexcept
Return a modifiable reference to tree's root.
bool avl_stack_empty() noexcept
virtual ~Gen_Avl_Tree() noexcept
Node * search_and_stack_avl(const Key &key, signed char &cmp_result) noexcept
static Node * doubleRotateLeft(Node *p) noexcept
Node * insert(Node *p) noexcept
Insert the node pointed by p in the tree.
Node * swapWithSuccessor(Node *p, Node *&pp) noexcept
void clean_avl_stack() noexcept
bool verify() const noexcept
Node * search_dup_and_stack_avl(const Key &key, signed char &cmp_result) noexcept
static Rotation_Type rotation_type(Node *p) noexcept
Gen_Avl_Tree(Compare __cmp=Compare()) noexcept
Node * remove(const Key &key) noexcept
Remove from an AVL tree the node containing key key.
constexpr Node * getRoot() const noexcept
Return a modifiable reference to tree's root.
constexpr Compare & key_comp() noexcept
The key type.
static Node * doubleRotateRight(Node *p) noexcept
void restore_avl_after_deletion(bool left_deficit) noexcept
static Node * rotateRight(Node *p) noexcept
static Node * rotateLeft(Node *p) noexcept
FixedStack< Node * > avl_stack
The type of node.
constexpr Node *& RLINK(Node *p) noexcept
Return the right tree of p.
constexpr Node *& LLINK(Node *p) noexcept
Return a pointer to left subtree.
Main namespace for Aleph-w library functions.
@ CmpGreater
First argument is greater than second.
@ CmpLess
First argument is less than second.
@ CmpEqual
Arguments are equal.
DynList< T > maps(const C &c, Op op)
Classic map operation.
AVL binary search tree with virtual destructor in its nodes.
AVL binary search tree with nodes without virtual destructor.
Iterator() noexcept=default
Default constructor creates an "end" iterator.
Iterator(const Gen_Avl_Tree &tree)
Stack implementations backed by dynamic or fixed arrays.
Utility functions for binary tree operations.