1 /* src/toolbox/avl.h - AVL tree implementation
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: avl.h 7860 2007-05-03 12:30:05Z twisti $
37 #include "vm/global.h"
40 /* define direction in an AVL node ********************************************/
46 /* tree comparator prototype **************************************************/
48 typedef s4 avl_comparator(const void *treenode, const void *node);
51 /* forward typedefs ***********************************************************/
53 typedef struct avl_tree_t avl_tree_t;
54 typedef struct avl_node_t avl_node_t;
57 /* avl_tree_t *****************************************************************/
60 #if defined(ENABLE_THREADS)
61 java_objectheader *lock; /* threads lock object */
63 avl_node_t *root; /* pointer to root node */
64 avl_comparator *comparator; /* pointer to comparison function */
65 s4 entries; /* contains number of entries */
69 /* avl_node_t *****************************************************************/
72 void *data; /* pointer to data structure */
73 s4 balance; /* the range of the field is -2...2 */
74 avl_node_t *childs[2]; /* pointers to the child nodes */
78 /* function prototypes ********************************************************/
80 avl_tree_t *avl_create(avl_comparator *comparator);
81 bool avl_insert(avl_tree_t *tree, void *data);
82 void *avl_find(avl_tree_t *tree, void *data);
85 void avl_dump(avl_node_t* node, s4 indent);
92 * These are local overrides for various environment variables in Emacs.
93 * Please do not remove this and leave it at the end of the file, where
94 * Emacs will automagically detect them.
95 * ---------------------------------------------------------------------