libcstl
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
rbtree.h File Reference

Go to the source code of this file.

Data Structures

struct  cstl_rbtree_node
 Node to anchor an element within a red-black tree. More...
 
struct  cstl_rbtree
 Red-black tree object. More...
 

Macros

#define CSTL_RBTREE_INITIALIZER(TYPE, MEMB, CMP, PRIV)
 Constant initialization of a cstl_rbtree object.
 
#define DECLARE_CSTL_RBTREE(NAME, TYPE, MEMB, CMP, PRIV)
 (Statically) declare and initialize a red-black tree
 

Functions

static void cstl_rbtree_init (struct cstl_rbtree *const t, cstl_compare_func_t *const cmp, void *const priv, const size_t off)
 Initialize a red-black tree object.
 
static size_t cstl_rbtree_size (const struct cstl_rbtree *const t)
 Get the number of objects in the tree.
 
void cstl_rbtree_insert (struct cstl_rbtree *t, void *e, void *p)
 Insert a new object into the tree.
 
static const void * cstl_rbtree_find (const struct cstl_rbtree *const t, const void *const e, const void **const p)
 Find an element within a tree.
 
void * cstl_rbtree_erase (struct cstl_rbtree *t, const void *e)
 Remove an element from the tree.
 
static void cstl_rbtree_clear (struct cstl_rbtree *const t, cstl_xtor_func_t *const clr, void *const priv)
 Remove all elements from the tree.
 
static void cstl_rbtree_swap (struct cstl_rbtree *const a, struct cstl_rbtree *const b)
 Swap the tree objects at the two given locations.
 
static int cstl_rbtree_foreach (const struct cstl_rbtree *const t, cstl_bintree_const_visit_func_t *const visit, void *const priv, const cstl_bintree_foreach_dir_t dir)
 Visit each element in a tree, calling a user-defined function for each visit.
 
static void cstl_rbtree_height (const struct cstl_rbtree *const t, size_t *const min, size_t *const max)
 Determine the maximum and minimum heights of a tree.