70 CR8R_AVL_INSERTED = 1,
89 void *data, uint64_t size,
90 int (*cmp)(
const cr8r_base_ft*,
const void*,
const void*),
115 cr8r_sla *sla, uint64_t size, uint64_t reserve,
116 int (*cmp)(
const cr8r_base_ft*,
const void*,
const void*),
327 #define CR8R_AVL_DATA(T, n) CR8R_FLA_CAST(T, (char*)((cr8r_avl_node*)(n))->data)
cr8r_avl_node * cr8r_avl_new(void *key, cr8r_avl_node *left, cr8r_avl_node *right, cr8r_avl_node *parent, char balance, cr8r_avl_ft *)
Allocate a new avl node and initialize it with given data.
bool cr8r_avl_ft_init(cr8r_avl_ft *, void *data, uint64_t size, int(*cmp)(const cr8r_base_ft *, const void *, const void *), int(*add)(cr8r_base_ft *, void *, void *), void *(*alloc)(cr8r_base_ft *), void(*free)(cr8r_base_ft *, void *))
Convenience function to initialize a cr8r_avl_ft.
int cr8r_avl_insert_update(cr8r_avl_node **r, void *key, cr8r_avl_ft *)
Create a new node in an avl tree or modify an existing one with a given value.
cr8r_avl_node * cr8r_avl_attach_exclusive(cr8r_avl_node *r, cr8r_avl_node *n, cr8r_avl_ft *)
Add a given node to an existing tree.
cr8r_avl_node * cr8r_avl_heappop_node(cr8r_avl_node **r, cr8r_avl_ft *)
Treat the avl tree as a max heap and remove the top element.
void cr8r_avl_reorder(cr8r_avl_node *r, cr8r_avl_ft *)
Reorder the tree so that it is sorted according to a new ordering function.
void cr8r_avl_heapify(cr8r_avl_node *r, cr8r_avl_ft *)
Convert the avl tree into a max heap in place.
cr8r_avl_node * cr8r_avl_last(cr8r_avl_node *n)
Find the node in the tree with the greatest key.
int cr8r_avl_remove(cr8r_avl_node **r, void *key, cr8r_avl_ft *)
Remove the node in an avl tree with a given value.
cr8r_avl_node * cr8r_avl_get(cr8r_avl_node *r, void *key, cr8r_avl_ft *)
Find the node matching a given element in a tree.
cr8r_avl_node * cr8r_avl_increase(cr8r_avl_node *n, cr8r_avl_ft *, int *is_duplicate)
Restore the binary search tree invariant after increasing the key for a single node.
cr8r_avl_node * cr8r_avl_root(cr8r_avl_node *n)
Find the root of the tree containing a given node.
cr8r_avl_node * cr8r_avl_remove_node(cr8r_avl_node *n, cr8r_avl_ft *)
Remove a given node from the tree containing it.
cr8r_avl_node * cr8r_avl_next(cr8r_avl_node *n)
Find the inorder successor of a node.
int cr8r_avl_insert(cr8r_avl_node **r, void *key, cr8r_avl_ft *)
Create a new node in an avl tree with a given value.
cr8r_avl_node * cr8r_avl_search(cr8r_avl_node *r, void *key, cr8r_avl_ft *)
Find the deepest node on the search path for a given key If there is a node in the tree with the give...
cr8r_avl_node * cr8r_avl_first_post(cr8r_avl_node *r)
Find the first node in a postorder traversal of the tree.
cr8r_avl_node * cr8r_avl_detach(cr8r_avl_node *n, cr8r_avl_ft *)
Remove a given node from the tree containing it but do not free it.
void cr8r_avl_delete(cr8r_avl_node *r, cr8r_avl_ft *)
Delete an entire avl tree, freeing all nodes in the process.
cr8r_avl_node * cr8r_avl_decrease(cr8r_avl_node *n, cr8r_avl_ft *, int *is_duplicate)
Restore the binary search tree invariant after decreasing the key for a single node.
cr8r_avl_node * cr8r_avl_attach(cr8r_avl_node *r, cr8r_avl_node *n, cr8r_avl_ft *, int *is_duplicate)
Add a given node to an existing tree.
void cr8r_avl_sift_down(cr8r_avl_node *r, cr8r_avl_ft *)
Treat the avl tree as a max heap and sift down a given node.
cr8r_avl_node * cr8r_avl_next_post(cr8r_avl_node *n)
Find the postorder successor of a given node.
cr8r_avl_node * cr8r_avl_lower_bound(cr8r_avl_node *r, void *key, cr8r_avl_ft *)
Find the greatest element l in the tree so that l <= key.
cr8r_avl_node * cr8r_avl_prev(cr8r_avl_node *n)
Find the inorder predecessor of a node.
cr8r_map_insert_result
Constants to test map like data structure insertion against where applicable.
cr8r_avl_node * cr8r_avl_first(cr8r_avl_node *r)
Find the node in the tree with the lowest key.
cr8r_avl_node * cr8r_avl_upper_bound(cr8r_avl_node *r, void *key, cr8r_avl_ft *)
Find the lowest element u in the tree so that key < u.
bool cr8r_avl_ft_initsla(cr8r_avl_ft *, cr8r_sla *sla, uint64_t size, uint64_t reserve, int(*cmp)(const cr8r_base_ft *, const void *, const void *), int(*add)(cr8r_base_ft *, void *, void *))
Convenience function to initialize a cr8r_avl_ft and associated slab allocator.
Function table for avl tree.
cr8r_base_ft base
Base function table values (data and size)
An avl tree node, also used to store an entire tree by synecdoche.
cr8r_avl_node * parent
Pointers to other nodes (can be NULL)
cr8r_avl_node * right
Pointers to other nodes (can be NULL)
cr8r_avl_node * left
Pointers to other nodes (can be NULL)
signed char balance
avl balance value; the height of the right subtree minus the height of the left subtree.
Base function table for all Crater containers.