2 * Copyright 2002 Adrian Thurston <thurston@cs.queensu.ca>
5 /* This file is part of Aapl.
7 * Aapl is free software; you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 2.1 of the License, or (at your option)
12 * Aapl is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with Aapl; if not, write to the Free Software Foundation, Inc., 59
19 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _AAPL_AVLTREE_H
23 #define _AAPL_AVLTREE_H
34 * \brief Basic AVL tree.
36 * AvlTree is the standard by-structure AVL tree. To use this structure the
37 * user must define an element type and give it the necessary properties. At
38 * the very least it must have a getKey() function that will be used to
39 * compare the relative ordering of elements and tree management data
40 * necessary for the AVL algorithm. An element type can acquire the management
41 * data by inheriting the AvlTreeEl class.
43 * AvlTree does not presume to manage the allocation of elements in the tree.
44 * The destructor will not delete the items in the tree, instead the elements
45 * must be explicitly de-allocated by the user if necessary and when it is
46 * safe to do so. The empty() routine will traverse the tree and delete all
49 * Since the tree does not manage the elements, it can contain elements that
50 * are allocated statically or that are part of another data structure.
52 * \include ex_avltree.cpp
57 #define BASE_EL(name) name
58 #define BASEKEY(name) name
59 #define AVLMEL_CLASSDEF class Element, class Key, class Compare = CmpOrd<Key>
60 #define AVLMEL_TEMPDEF class Element, class Key, class Compare
61 #define AVLMEL_TEMPUSE Element, Key, Compare
62 #define AvlTree AvlTree
64 #include "avlcommon.h"
68 #undef AVLMEL_CLASSDEF
73 #endif /* _AAPL_AVLTREE_H */