11 #define rbtree_item(ptr, type, member) \
12 ((type*)(((char*)ptr) - offsetof(type, member)))
14 typedef struct rbtree rbtree_t;
19 const rbtree_node_t *rhs);
72 rbtree_insert(rbtree_t *tree,
92 const rbtree_node_t *node);
void(* rbtree_node_destructor_t)(rbtree_node_t *Node)
rbtree node destructor.
Definition: rbtree.h:17
void rbtree_init(rbtree_t *tree, rbtree_node_comparator_t comparator)
Initializes an rbtree.
rbtree_node_t * rbtree_node_prev(const rbtree_node_t *node)
Gets the previous node from an rbtree node.
void rbtree_insert_multi(rbtree_t *tree, rbtree_node_t *node)
Inserts multiple nodes into an rbtree.
size_t rbtree_size(const rbtree_t *tree)
Gets the size of an rbtree.
__attribute__((warn_unused_result)) rbtree_node_t *rbtree_insert(rbtree_t *tree
Inserts a node into an rbtree.
rbtree_node_t * rbtree_min(const rbtree_t *tree)
Gets the minimum node of an rbtree.
rbtree_node_t * rbtree_max(const rbtree_t *tree)
Gets the maximum node of an rbtree.
rbtree_node_t * rbtree_find(const rbtree_t *tree, const rbtree_node_t *node)
Finds a node within an rbtree.
rbtree_node_t * rbtree_remove(rbtree_t *tree, rbtree_node_t *node, rbtree_node_destructor_t destructor)
Removes a node from an rbtree.
void rbtree_clear(rbtree_t *tree, rbtree_node_destructor_t destructor)
Clears an rbtree.
int rbtree_empty(const rbtree_t *tree)
Gets whether an rbtree is empty.
int(* rbtree_node_comparator_t)(const rbtree_node_t *lhs, const rbtree_node_t *rhs)
rbtree node comparator.
Definition: rbtree.h:18
rbtree_node_t * rbtree_node_next(const rbtree_node_t *node)
Gets the next node from an rbtree node.
An rbtree node.
Definition: rbtree.h:23
uintptr_t parent_color
Parent color.
Definition: rbtree.h:24
rbtree_node_t * child[2]
Node children.
Definition: rbtree.h:25
An rbtree.
Definition: rbtree.h:30
size_t size
Size.
Definition: rbtree.h:33
rbtree_node_comparator_t comparator
Node comparator.
Definition: rbtree.h:32
rbtree_node_t * root
Root node.
Definition: rbtree.h:31