5 AVL balanced tree library
7 > Created (Julienne Walker): June 17, 2003
8 > Modified (Julienne Walker): September 24, 2005
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.
32 typedef struct jsw_avltree jsw_avltree_t;
33 typedef struct jsw_avltrav jsw_avltrav_t;
35 /* User-defined item handling */
36 typedef int (*cmp_f) ( const void *p1, const void *p2 );
37 typedef void *(*dup_f) ( void *p );
38 typedef void (*rel_f) ( void *p );
40 /* AVL tree functions */
41 jsw_avltree_t *jsw_avlnew ( cmp_f cmp, dup_f dup, rel_f rel );
42 void jsw_avldelete ( jsw_avltree_t *tree );
43 void *jsw_avlfind ( jsw_avltree_t *tree, void *data );
44 int jsw_avlinsert ( jsw_avltree_t *tree, void *data );
45 int jsw_avlerase ( jsw_avltree_t *tree, void *data );
46 size_t jsw_avlsize ( jsw_avltree_t *tree );
48 /* Traversal functions */
49 jsw_avltrav_t *jsw_avltnew ( void );
50 void jsw_avltdelete ( jsw_avltrav_t *trav );
51 void *jsw_avltfirst ( jsw_avltrav_t *trav, jsw_avltree_t *tree );
52 void *jsw_avltlast ( jsw_avltrav_t *trav, jsw_avltree_t *tree );
53 void *jsw_avltnext ( jsw_avltrav_t *trav );
54 void *jsw_avltprev ( jsw_avltrav_t *trav );