diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 01:49:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 01:49:02 +0000 |
commit | 5de3dd4762ca33a0f92e79ffa4fe2ff67069d531 (patch) | |
tree | bad482b7afa4cdf47422d60a5dd2c61c7e333b09 /microbe/btreebase.h | |
download | ktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.tar.gz ktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.zip |
Added KDE3 version of ktechlab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1095338 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'microbe/btreebase.h')
-rw-r--r-- | microbe/btreebase.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/microbe/btreebase.h b/microbe/btreebase.h new file mode 100644 index 0000000..d8d1040 --- /dev/null +++ b/microbe/btreebase.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2004-2005 by Daniel Clarke * + * daniel.jc@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef BTREEBASE_H +#define BTREEBASE_H +#include "microbe.h" +#include "btreenode.h" + +/** +@short This holds a pointer to the start of the tree, and provides the traversal code. +@author Daniel Clarke +*/ +class BTreeBase{ +public: + BTreeBase(); + ~BTreeBase(); + + /** Return a pointer to the root node of the tree */ + BTreeNode *root() const { return m_root; } + + /** Set the root node of the tree */ + void setRoot(BTreeNode *root){m_root = root; } + + /** Link the node into the tree. a.t.m all this really + does it sets the parent/child relationship pointers, + but is used in case something needs to be changed in the future + Added to the left if left == true or the right if left == false */ + void addNode(BTreeNode *parent, BTreeNode *node, bool left); + + /** Deletes all nodes in tree and zeros pointer to root node */ + void deleteTree(); + + /** Tidies the tree up; merging constants and removing redundant branches */ + void pruneTree(BTreeNode *root, bool conditionalRoot = true); + + /** Put a node in place of another, linking it correctly into the parent. */ + void replaceNode(BTreeNode *node, BTreeNode *replacement); + +protected: + BTreeNode *m_root; +}; + +#endif |