search trees (tsearch: a balanced tree of pointers the caller owns) and linear search in an array.
More...
Go to the source code of this file.
|
| void * | tsearch (const void *key, void **root, int(*compare)(const void *, const void *)) |
| | find key in the tree at *root, or add it.
|
| void * | tfind (const void *key, void *const *root, int(*compare)(const void *, const void *)) |
| | find key; NULL when it is not in the tree
|
| void * | tdelete (const void *restrict key, void **restrict root, int(*compare)(const void *, const void *)) |
| | remove key from the tree.
|
| void | twalk (const void *root, void(*action)(const void *node, VISIT which, int depth)) |
| | call action for each node, in the order of the tree, with its depth
|
| void | tdestroy (void *root, void(*free_key)(void *key)) |
| | free every node, calling free_key with each key (GNU)
|
| void * | lfind (const void *key, const void *base, size_t *count, size_t size, int(*compare)(const void *, const void *)) |
| | find key in the array of *count items of size bytes; NULL if it is not there
|
| void * | lsearch (const void *key, void *base, size_t *count, size_t size, int(*compare)(const void *, const void *)) |
| | as lfind, but add key at the end (and count it) when it is not there
|
search trees (tsearch: a balanced tree of pointers the caller owns) and linear search in an array.
◆ __compar_fn_t
| typedef int(*) __compar_fn_t(const void *, const void *) |
◆ VISIT
| Enumerator |
|---|
| preorder | |
| postorder | |
| endorder | |
| leaf | |
◆ tsearch()
| void * tsearch |
( |
const void * | key, |
|
|
void ** | root, |
|
|
int(* | compare )(const void *, const void *) ) |
find key in the tree at *root, or add it.
- Returns
- a pointer to the node's key pointer (the found one, or key), or NULL when there is no memory.
◆ tfind()
| void * tfind |
( |
const void * | key, |
|
|
void *const * | root, |
|
|
int(* | compare )(const void *, const void *) ) |
find key; NULL when it is not in the tree
◆ tdelete()
| void * tdelete |
( |
const void *restrict | key, |
|
|
void **restrict | root, |
|
|
int(* | compare )(const void *, const void *) ) |
remove key from the tree.
- Returns
- a pointer to the parent's key pointer (any non-NULL pointer when the root was removed), or NULL when key is not in the tree.
◆ twalk()
| void twalk |
( |
const void * | root, |
|
|
void(* | action )(const void *node, VISIT which, int depth) ) |
call action for each node, in the order of the tree, with its depth
◆ tdestroy()
| void tdestroy |
( |
void * | root, |
|
|
void(* | free_key )(void *key) ) |
free every node, calling free_key with each key (GNU)
◆ lfind()
| void * lfind |
( |
const void * | key, |
|
|
const void * | base, |
|
|
size_t * | count, |
|
|
size_t | size, |
|
|
int(* | compare )(const void *, const void *) ) |
find key in the array of *count items of size bytes; NULL if it is not there
◆ lsearch()
| void * lsearch |
( |
const void * | key, |
|
|
void * | base, |
|
|
size_t * | count, |
|
|
size_t | size, |
|
|
int(* | compare )(const void *, const void *) ) |
as lfind, but add key at the end (and count it) when it is not there