]> git.sur5r.net Git - openldap/blob - include/avl.h
a runqueue for periodic thread execution (for syncrepl)
[openldap] / include / avl.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted only as authorized by the OpenLDAP
8  * Public License.  A copy of this license is available at
9  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10  * top-level directory of the distribution.
11  */
12 /* Portions
13  * Copyright (c) 1993 Regents of the University of Michigan.
14  * All rights reserved.
15  *
16  * Redistribution and use in source and binary forms are permitted
17  * provided that this notice is preserved and that due credit is given
18  * to the University of Michigan at Ann Arbor. The name of the University
19  * may not be used to endorse or promote products derived from this
20  * software without specific prior written permission. This software
21  * is provided ``as is'' without express or implied warranty.
22  */
23 /* avl.h - avl tree definitions */
24
25
26 #ifndef _AVL
27 #define _AVL
28
29 #include <ldap_cdefs.h>
30
31 /*
32  * this structure represents a generic avl tree node.
33  */
34
35 LDAP_BEGIN_DECL
36
37 typedef struct avlnode Avlnode;
38
39 #ifdef AVL_INTERNAL
40 struct avlnode {
41         void*           avl_data;
42         signed int              avl_bf;
43         struct avlnode  *avl_left;
44         struct avlnode  *avl_right;
45 };
46
47 #define NULLAVL ((Avlnode *) NULL)
48
49 /* balance factor values */
50 #define LH      (-1)
51 #define EH      0
52 #define RH      1
53
54 /* avl routines */
55 #define avl_getone(x)   ((x) == 0 ? 0 : (x)->avl_data)
56 #define avl_onenode(x)  ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
57
58 #endif /* AVL_INTERNALS */
59
60 typedef int             (*AVL_APPLY) LDAP_P((void *, void*));
61 typedef int             (*AVL_CMP) LDAP_P((const void*, const void*));
62 typedef int             (*AVL_DUP) LDAP_P((void*, void*));
63 typedef void    (*AVL_FREE) LDAP_P((void*));
64
65 LDAP_AVL_F( int )
66 avl_free LDAP_P(( Avlnode *root, AVL_FREE dfree ));
67
68 LDAP_AVL_F( int )
69 avl_insert LDAP_P((Avlnode **, void*, AVL_CMP, AVL_DUP));
70
71 LDAP_AVL_F( void* )
72 avl_delete LDAP_P((Avlnode **, void*, AVL_CMP));
73
74 LDAP_AVL_F( void* )
75 avl_find LDAP_P((Avlnode *, const void*, AVL_CMP));
76
77 LDAP_AVL_F( void* )
78 avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP));
79
80 #ifdef AVL_NONREENTRANT
81 LDAP_AVL_F( void* )
82 avl_getfirst LDAP_P((Avlnode *));
83
84 LDAP_AVL_F( void* )
85 avl_getnext LDAP_P((void));
86 #endif
87
88 LDAP_AVL_F( int )
89 avl_dup_error LDAP_P((void*, void*));
90
91 LDAP_AVL_F( int )
92 avl_dup_ok LDAP_P((void*, void*));
93
94 LDAP_AVL_F( int )
95 avl_apply LDAP_P((Avlnode *, AVL_APPLY, void*, int, int));
96
97 LDAP_AVL_F( int )
98 avl_prefixapply LDAP_P((Avlnode *, void*, AVL_CMP, void*, AVL_CMP, void*, int));
99
100 /* apply traversal types */
101 #define AVL_PREORDER    1
102 #define AVL_INORDER     2
103 #define AVL_POSTORDER   3
104 /* what apply returns if it ran out of nodes */
105 #define AVL_NOMORE      (-6)
106
107 LDAP_END_DECL
108
109 #endif /* _AVL */