1 /* src/toolbox/avl.h - AVL tree implementation
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33 #include "threads/mutex.hpp"
35 #include "vm/global.h"
38 /* define direction in an AVL node ********************************************/
44 /* tree comparator prototype **************************************************/
46 typedef s4 avl_comparator(const void *treenode, const void *node);
49 /* forward typedefs ***********************************************************/
51 typedef struct avl_tree_t avl_tree_t;
52 typedef struct avl_node_t avl_node_t;
55 /* avl_tree_t *****************************************************************/
58 Mutex* mutex; ///< Mutex to lock the tree.
59 avl_node_t *root; /* pointer to root node */
60 avl_comparator *comparator; /* pointer to comparison function */
61 s4 entries; /* contains number of entries */
65 /* avl_node_t *****************************************************************/
68 void *data; /* pointer to data structure */
69 s4 balance; /* the range of the field is -2...2 */
70 avl_node_t *childs[2]; /* pointers to the child nodes */
74 /* 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);
96 * These are local overrides for various environment variables in Emacs.
97 * Please do not remove this and leave it at the end of the file, where
98 * Emacs will automagically detect them.
99 * ---------------------------------------------------------------------
102 * indent-tabs-mode: t