5 Bacula® - The Network Backup Solution
7 Copyright (C) 2005-2006 Free Software Foundation Europe e.V.
9 The main author of Bacula is Kern Sibbald, with contributions from
10 many others, a complete list can be found in the file AUTHORS.
11 This program is Free Software; you can redistribute it and/or
12 modify it under the terms of version two of the GNU General Public
13 License as published by the Free Software Foundation plus additions
14 that are listed in the file LICENSE.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 Bacula® is a registered trademark of John Walker.
27 The licensor of Bacula is the Free Software Foundation Europe
28 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
29 Switzerland, email:ftf@fsfeurope.org.
33 /* ========================================================================
35 * red-black binary tree routines -- btree.h
44 * There is a lot of extra casting here to work around the fact
45 * that some compilers (Sun and Visual C++) do not accept
46 * (bnode *) as an lvalue on the left side of an equal.
48 * Loop var through each member of list
50 #define foreach_btree(var, tree) \
51 for(*((bnode **)&(var))=(tree)->first(); (*((bnode **)&(var))=(tree)->next((bnode *)var)); )
54 #define foreach_btree(var, tree) \
55 for((var)=(tree)->first(); (((bnode *)(var))=(tree)->next((bnode *)var)); )
66 class btree : public SMARTALLOC {
70 void left_rotate(bnode *item);
71 void right_rotate(bnode *item);
74 ~btree() { destroy(); }
76 bnode *insert(bnode *item, int compare(bnode *item1, bnode *item2));
77 bnode *search(bnode *item, int compare(bnode *item1, bnode *item2));
79 bnode *next(bnode *item);
80 bnode *any(bnode *item);
81 void remove(bnode *item);
88 * This allows us to do explicit initialization,
89 * allowing us to mix C++ classes inside malloc'ed
90 * C structures. Define before called in constructor.
92 inline void btree::init()
99 /* Constructor with link at head of item */
100 inline btree::btree(void) : head(0), num_items(0)
104 inline int btree::size() const