$Revision: 1.19 $
Radix tree (rx). rx_tree.c - functions to operate on trees
(creation/deletion/finding).
Status: NOT REVUED, TESTED, INCOMPLETE
Design and implementation by: Marek Bukowy
Included Files
- #include <include/erroutines.h>
- #include <include/iproutines.h>
- #include <include/memwrap.h>
- #include <include/rxroutines.h>
Preprocessor definitions
#define RX_IMPL
creates a (top) tree for the space, fills out sql table of trees
generates a tablename for a tree (if NONE)
updates LL of trees
MT-note: locks/unlocks the forest (still to be done)
er_ret_t RX_tree_cre ( char* prefixstr, rx_fam_t fam_id, rx_mem_mt mem_mode, rx_subtree_mt subtrees, rx_tree_t** treestore )
- char* prefixstr
- prefix the tree will cover (string)
- rx_fam_t fam_id
- &nbs;
- rx_mem_mt mem_mode
- &nbs;
- rx_subtree_mt subtrees
- one of NONE, AUTO, HAND
- rx_tree_t** treestore
- &nbs;
er_ret_t RX_treecheck ( rx_tree_t* tree, int datatoo, rx_treecheck_t* errorfound )
int rx_check_walk_tree ( rx_node_t* node, rx_node_t* parent_node, int nodecounter, rx_treecheck_t* checkstruct )
go down the tree and delete all nodes of the tree.
the function is called recursively with level increased
it stops recursing when no child nodes are found or maxlevel is reached.
therefore the initial call must set level to 0.
the nodecounter increments at every node, and is the return value
of the function. So start with 0 to get the number of nodes traversed.
ERROR HANDLING IS DIFFERENT HERE!
Unlike other functions it is not the return value:
The error code from the func function IF DEFINED (== not NULL ) goes
to the variable pointed to by the last parameter.
XXX: nodecounter is ALWAYS passed as 0, so should probably be removed from
calling parameter list, shane 2001-02-01
void rx_delete_dataleaves ( void* element_data, void* result_ptr )
int rx_delete_tree ( rx_tree_t* tree, rx_node_t* node, int maxlevel, int level, int nodecounter, void* userptr )
void rx_delete_treenode ( rx_tree_t* tree, rx_node_t* curnode )
go down the tree calling func on every node.
(func takes the node pointer and the current level)
the function is called recursively with level increased
it stops recursing when no child nodes are found or maxlevel is reached.
therefore the initial call must set level to 0.
the nodecounter increments at every node, and is the return value
of the function. So start with 0 to get the number of nodes traversed.
ERROR HANDLING IS DIFFERENT HERE!
Unlike other functions it is not the return value:
The error code from the func function IF DEFINED (== not NULL ) goes
to the variable pointed to by the last parameter.
XXX: nodecounter is ALWAYS passed as 0, so should probably be removed from
calling parameter list, shane 2001-02-01
int rx_walk_tree ( rx_node_t* node, er_ret_t (*func)(rx_node_t* node,int level,int nodecounter,void* userptr), rx_walk_mt walk_mode, int maxlevel, int level, int nodecounter, void* userptr, er_ret_t* err )