libusual
0.1
|
Crit-bit tree / binary radix tree. More...
Typedefs | |
typedef size_t(* | cbtree_getkey_func )(void *ctx, void *obj, const void **dst_p) |
returns length of the key | |
typedef bool(* | cbtree_walker_func )(void *ctx, void *obj) |
walk over tree | |
Functions | |
struct CBTree * | cbtree_create (cbtree_getkey_func obj_key_cb, cbtree_walker_func obj_free_cb, void *cb_ctx, CxMem *cx) |
Create new tree. | |
void | cbtree_destroy (struct CBTree *tree) |
frees all resources allocated. | |
bool | cbtree_insert (struct CBTree *tree, void *obj) _MUSTCHECK |
Inserts new node to tree. | |
bool | cbtree_delete (struct CBTree *tree, const void *key, size_t klen) |
Removed node from tree. | |
void * | cbtree_lookup (struct CBTree *tree, const void *key, size_t klen) |
Lookup a key. | |
bool | cbtree_walk (struct CBTree *tree, cbtree_walker_func cb_func, void *cb_arg) |
Walk over tree. |
Crit-bit tree / binary radix tree.
typedef size_t(* cbtree_getkey_func)(void *ctx, void *obj, const void **dst_p) |
returns length of the key
typedef bool(* cbtree_walker_func)(void *ctx, void *obj) |
walk over tree
struct CBTree* cbtree_create | ( | cbtree_getkey_func | obj_key_cb, |
cbtree_walker_func | obj_free_cb, | ||
void * | cb_ctx, | ||
CxMem * | cx | ||
) | [read] |
Create new tree.
obj_key_cb | callback to get the key for a object |
obj_free_cb | callback to free the object when tree node is freed (optional) |
cb_ctx | extra pointer passed to callbacks |
cx | memory context where from allocate |
void cbtree_destroy | ( | struct CBTree * | tree | ) |
frees all resources allocated.
If obj_free_cb is non-NULL, it will be called per each object.
bool cbtree_insert | ( | struct CBTree * | tree, |
void * | obj | ||
) |
Inserts new node to tree.
bool cbtree_delete | ( | struct CBTree * | tree, |
const void * | key, | ||
size_t | klen | ||
) |
Removed node from tree.
If obj_free_cb is non-NULL, it will be called for the object.
void* cbtree_lookup | ( | struct CBTree * | tree, |
const void * | key, | ||
size_t | klen | ||
) |
Lookup a key.
bool cbtree_walk | ( | struct CBTree * | tree, |
cbtree_walker_func | cb_func, | ||
void * | cb_arg | ||
) |
Walk over tree.