90#define CSTL_BINTREE_INITIALIZER(TYPE, MEMB, CMP, PRIV) \
94 .off = offsetof(TYPE, MEMB), \
114#define DECLARE_CSTL_BINTREE(NAME, TYPE, MEMB, CMP, PRIV) \
115 struct cstl_bintree NAME = \
116 CSTL_BINTREE_INITIALIZER(TYPE, MEMB, CMP, PRIV)
192 const struct cstl_bintree * bt,
const void * e,
const void ** p);
331 size_t * min,
size_t * max);
365 __cstl_bintree_child_func_t *,
366 __cstl_bintree_child_func_t *);
void cstl_xtor_func_t(void *obj, void *priv)
Type for functions called to construct, clear, or destroy an object.
int cstl_compare_func_t(const void *obj1, const void *obj2, void *priv)
Function type for comparing (in)equality of two objects.
void cstl_bintree_insert(struct cstl_bintree *bt, void *e, void *p)
Insert a new object into the tree.
cstl_bintree_visit_order_t
Enumeration indicating the order in which a tree element is being visited during cstl_bintree_foreach...
static size_t cstl_bintree_size(const struct cstl_bintree *const bt)
Get the number of objects in the tree.
static void cstl_bintree_init(struct cstl_bintree *const bt, cstl_compare_func_t *const cmp, void *const priv, const size_t off)
Initialize a binary tree object.
cstl_bintree_foreach_dir_t
Enumeration indicating the order in which elements in a tree are visited during cstl_bintree_foreach(...
int cstl_bintree_const_visit_func_t(const void *e, cstl_bintree_visit_order_t ord, void *p)
The type of visit function associated with cstl_bintree_foreach()
void cstl_bintree_height(const struct cstl_bintree *bt, size_t *min, size_t *max)
Determine the maximum and minimum heights of a tree.
int cstl_bintree_foreach(const struct cstl_bintree *bt, cstl_bintree_const_visit_func_t *visit, void *priv, cstl_bintree_foreach_dir_t dir)
Visit each element in a tree, calling a user-defined function for each visit.
const void * cstl_bintree_find(const struct cstl_bintree *bt, const void *e, const void **p)
Find an element within a tree.
void cstl_bintree_swap(struct cstl_bintree *a, struct cstl_bintree *b)
Swap the tree objects at the two given locations.
void * cstl_bintree_erase(struct cstl_bintree *bt, const void *e)
Remove an element from the tree.
void cstl_bintree_clear(struct cstl_bintree *bt, cstl_xtor_func_t *clr, void *priv)
Remove all elements from the tree.
@ CSTL_BINTREE_VISIT_ORDER_LEAF
The only visit to an element that has no children.
@ CSTL_BINTREE_VISIT_ORDER_POST
The last visit to an element, after both children have/would have been visited.
@ CSTL_BINTREE_VISIT_ORDER_MID
The second visit to an element, after its first child has/would have been visited.
@ CSTL_BINTREE_VISIT_ORDER_PRE
The first visit to an element that has at least one child.
@ CSTL_BINTREE_FOREACH_DIR_REV
Each element in the tree is visited from right-to-left.
@ CSTL_BINTREE_FOREACH_DIR_FWD
Each element in the tree is visited from left-to-right.
Node to anchor an element within a binary tree.