|
mdcore
0.1.5
|
Defines | |
| #define | error(id) ( btree_err = errs_register( id , btree_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) ) |
Functions | |
| int | btree_delete (struct btree *b, int key, void **res) |
| Delete a key from the btree. | |
| int | btree_find (struct btree *b, int key, void **res) |
| Retrieve the data for a given key. | |
| int | btree_dump (struct btree *b, FILE *out) |
| Dump the given btree. | |
| int | btree_map (struct btree *b, int(*func)(void *, void *), void *data) |
| Apply a given function to all data in a btree. | |
| int | btree_insert (struct btree *b, int key, void *data) |
| Insert a key/data pair into the given btree. | |
| int | btree_releasenode (struct btree *b, struct btree_node *n) |
| Return a btree_node to the btree's cache. | |
| struct btree_node * | btree_getnode (struct btree *b) |
| get a btree_node from the btree's cache. | |
| int | btree_init (struct btree *b) |
| Initialize the given btree. | |
Variables | |
| char * | btree_err_msg [4] |
| int | btree_err = btree_err_ok |
| #define error | ( | id | ) | ( btree_err = errs_register( id , btree_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) ) |
| int btree_delete | ( | struct btree * | b, |
| int | key, | ||
| void ** | res | ||
| ) |
| int btree_dump | ( | struct btree * | b, |
| FILE * | out | ||
| ) |
| int btree_find | ( | struct btree * | b, |
| int | key, | ||
| void ** | res | ||
| ) |
Retrieve the data for a given key.
| b | the btree in which to search. |
| key | the key to search for. |
| res | a pointer to a pointer in which the address of the data will be written. |
Looks for the given key and copies its data pointer to the address given by res.
| struct btree_node* btree_getnode | ( | struct btree * | b | ) | [read] |
get a btree_node from the btree's cache.
| the | btree. |
NULL if an error occured (see btree_err). | int btree_init | ( | struct btree * | b | ) |
| int btree_insert | ( | struct btree * | b, |
| int | key, | ||
| void * | data | ||
| ) |
Insert a key/data pair into the given btree.
| b | the btree. |
| key | the integer key. |
| data | a pointer to the data associated with key. |
If a node with the given key already exists, the data pointer is replaced.
Apply a given function to all data in a btree.
| b | the btree. |
| func | the funciton, which should be of the type btree_maptype. |
| data | a pointer that will be passed to func with each call. |
If func returns < 0 for any node, the traversal is interrupted and an error is returned.
| int btree_releasenode | ( | struct btree * | b, |
| struct btree_node * | n | ||
| ) |
Return a btree_node to the btree's cache.
| b | the btree. |
| n | the btree_node |
NULL if an error occured (see btree_err). | int btree_err = btree_err_ok |
ID of the last error.
| char* btree_err_msg[4] |
{
"Nothing bad happened.",
"An unexpected NULL pointer was encountered.",
"A call to malloc failed, probably due to insufficient memory.",
"The user-supplied mapping function returned an error."
}
1.7.6.1