libcstl
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
bintree.h File Reference

Go to the source code of this file.

Data Structures

struct  cstl_bintree_node
 Node to anchor an element within a binary tree. More...
 
struct  cstl_bintree
 Binary tree object. More...
 

Macros

#define CSTL_BINTREE_INITIALIZER(TYPE, MEMB, CMP, PRIV)
 Constant initialization of a cstl_bintree object.
 
#define DECLARE_CSTL_BINTREE(NAME, TYPE, MEMB, CMP, PRIV)
 (Statically) declare and initialize a binary tree
 

Typedefs

typedef 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()
 

Enumerations

enum  cstl_bintree_visit_order_t { CSTL_BINTREE_VISIT_ORDER_PRE , CSTL_BINTREE_VISIT_ORDER_MID , CSTL_BINTREE_VISIT_ORDER_POST , CSTL_BINTREE_VISIT_ORDER_LEAF }
 Enumeration indicating the order in which a tree element is being visited during cstl_bintree_foreach() More...
 
enum  cstl_bintree_foreach_dir_t { CSTL_BINTREE_FOREACH_DIR_FWD , CSTL_BINTREE_FOREACH_DIR_REV }
 Enumeration indicating the order in which elements in a tree are visited during cstl_bintree_foreach() More...
 

Functions

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.
 
static size_t cstl_bintree_size (const struct cstl_bintree *const bt)
 Get the number of objects in the tree.
 
void cstl_bintree_insert (struct cstl_bintree *bt, void *e, void *p)
 Insert a new object into the tree.
 
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_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.
 
void cstl_bintree_swap (struct cstl_bintree *a, struct cstl_bintree *b)
 Swap the tree objects at the two given locations.
 
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.
 
void cstl_bintree_height (const struct cstl_bintree *bt, size_t *min, size_t *max)
 Determine the maximum and minimum heights of a tree.