5 Red Black balanced tree library
7 > Created (Julienne Walker): August 23, 2003
8 > Modified (Julienne Walker): March 14, 2008
10 This code is in the public domain. Anyone may
11 use it or change it in any way that they see
12 fit. The author assumes no responsibility for
13 damages incurred through use of the original
14 code or any variations thereof.
16 It is requested, but not required, that due
17 credit is given to the original author and
18 anyone who has modified the code through
19 a header comment, such as this one.
24 typedef struct jsw_rbtree jsw_rbtree_t;
25 typedef struct jsw_rbtrav jsw_rbtrav_t;
27 /* User-defined item handling */
28 typedef int (*cmp_f) ( const void *p1, const void *p2 );
29 typedef void *(*dup_f) ( void *p );
30 typedef void (*rel_f) ( void *p );
32 /* Red Black tree functions */
33 jsw_rbtree_t *jsw_rbnew ( cmp_f cmp, dup_f dup, rel_f rel );
34 void jsw_rbdelete ( jsw_rbtree_t *tree );
35 void *jsw_rbfind ( jsw_rbtree_t *tree, void *data );
36 int jsw_rbinsert ( jsw_rbtree_t *tree, void *data );
37 int jsw_rberase ( jsw_rbtree_t *tree, void *data );
38 size_t jsw_rbsize ( jsw_rbtree_t *tree );
40 /* Traversal functions */
41 jsw_rbtrav_t *jsw_rbtnew ( void );
42 void jsw_rbtdelete ( jsw_rbtrav_t *trav );
43 void *jsw_rbtfirst ( jsw_rbtrav_t *trav, jsw_rbtree_t *tree );
44 void *jsw_rbtlast ( jsw_rbtrav_t *trav, jsw_rbtree_t *tree );
45 void *jsw_rbtnext ( jsw_rbtrav_t *trav );
46 void *jsw_rbtprev ( jsw_rbtrav_t *trav );