00001
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #ifndef _lub_bintree_h
00104 #define _lub_bintree_h
00105 #include <stddef.h>
00106
00107
00108
00109
00118 typedef struct lub_bintree_node_s lub_bintree_node_t;
00122 struct lub_bintree_node_s
00123 {lub_bintree_node_t *left; lub_bintree_node_t *right;
00126 };
00127
00140 typedef int
00141 lub_bintree_compare_fn(const void *clientnode,
00142 const void *clientkey);
00148 #define lub_bintree_MAX_KEY_STORAGE (200)
00149
00154 typedef struct lub_bintree_key_s lub_bintree_key_t;
00158 struct lub_bintree_key_s
00159 {char storage[lub_bintree_MAX_KEY_STORAGE];int magic;
00162 };
00163
00174 typedef void
00175 lub_bintree_getkey_fn(const void *clientnode,
00176 lub_bintree_key_t *key);
00177
00181 typedef struct lub_bintree_s lub_bintree_t;
00185 struct lub_bintree_s
00186 {lub_bintree_node_t *root;size_t node_offset;lub_bintree_compare_fn *compareFn;lub_bintree_getkey_fn *getkeyFn;
00191 };
00192
00196 typedef struct lub_bintree_iterator_s lub_bintree_iterator_t;
00200 struct lub_bintree_iterator_s
00201 {lub_bintree_t *tree;lub_bintree_key_t key;
00204 };
00205
00206
00207
00208
00216 extern void
00217 lub_bintree_init(
00221 lub_bintree_t *tree,
00227 size_t node_offset,
00232 lub_bintree_compare_fn compareFn,
00236 lub_bintree_getkey_fn getkeyFn
00237 );
00238
00248 extern void
00249 lub_bintree_node_init(
00253 lub_bintree_node_t *node
00254 );
00255
00256
00257
00258
00273 extern int
00274 lub_bintree_insert(
00278 lub_bintree_t *tree,
00283 void *clientnode
00284 );
00285
00297 extern void
00298 lub_bintree_remove(
00302 lub_bintree_t *tree,
00306 void *clientnode
00307 );
00308
00309
00310
00311
00320 extern void *
00321 lub_bintree_findfirst(
00325 lub_bintree_t *tree
00326 );
00327
00336 extern void *
00337 lub_bintree_findlast(
00341 lub_bintree_t *tree
00342 );
00343
00353 extern void *
00354 lub_bintree_find(
00358 lub_bintree_t *tree,
00362 const void *key
00363 );
00364
00376 extern void *
00377 lub_bintree_findnext(
00381 lub_bintree_t *tree,
00385 const void *key
00386 );
00387
00399 extern void *
00400 lub_bintree_findprevious(
00404 lub_bintree_t *tree,
00408 const void *key
00409 );
00410
00411
00412
00413
00425 extern void
00426 lub_bintree_iterator_init(
00430 lub_bintree_iterator_t *iter,
00434 lub_bintree_t *tree,
00438 const void *clientnode
00439 );
00440
00452 extern void *
00453 lub_bintree_iterator_next(
00457 lub_bintree_iterator_t *iter
00458 );
00459
00471 extern void *
00472 lub_bintree_iterator_previous(
00476 lub_bintree_iterator_t *iter
00477 );
00485 extern void
00486 lub_bintree_dump(
00490 lub_bintree_t *tree
00491 );
00492
00493 #endif
00494