00001
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __PATRICIA_TREE_H__
00031 #define __PATRICIA_TREE_H__
00032
00034 typedef struct _apatnode {
00042 union {
00043 void *data;
00044 int thres_bit;
00045 } value;
00046 struct _apatnode *left0;
00047 struct _apatnode *right1;
00048 } APATNODE;
00049
00051 typedef struct _patnode {
00059 union {
00060 int data;
00061 int thres_bit;
00062 } value;
00063 struct _patnode *left0;
00064 struct _patnode *right1;
00065 } PATNODE;
00066
00067 int testbit(char *str, int bitplace);
00068 int testbit_max(char *str, int bitplace, int maxbitplace);
00069 int where_the_bit_differ(char *str1, char *str2);
00070 PATNODE *make_ptree(char **words, int *data, int wordsnum, int bitplace);
00071 void disp_ptree(PATNODE *node, int level);
00072 int ptree_search_data(char *str, PATNODE *rootnode);
00073 PATNODE *ptree_make_root_node(int data);
00074 void ptree_add_entry(char *str, int data, char *matchstr, PATNODE **rootnode);
00075 void free_ptree(PATNODE *rootnode);
00076
00077 void *aptree_search_data(char *str, APATNODE *rootnode);
00078 APATNODE *aptree_make_root_node(void *data);
00079 void aptree_add_entry(char *str, void *data, char *matchstr, APATNODE **rootnode);
00080 void aptree_remove_entry(char *str, APATNODE **rootnode);
00081 void aptree_traverse_and_do(APATNODE *node, void (*callback)(void *));
00082 void free_aptree(APATNODE *rootnode);
00083
00084 #endif