BTreeBase Class Reference

This holds a pointer to the start of the tree, and provides the traversal code. More...

#include <btreebase.h>

Collaboration diagram for BTreeBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BTreeBase ()
 ~BTreeBase ()
BTreeNoderoot () const
void setRoot (BTreeNode *root)
void addNode (BTreeNode *parent, BTreeNode *node, bool left)
void deleteTree ()
void pruneTree (BTreeNode *root, bool conditionalRoot=true)
void replaceNode (BTreeNode *node, BTreeNode *replacement)

Protected Attributes

BTreeNodem_root

Detailed Description

This holds a pointer to the start of the tree, and provides the traversal code.

Author:
Daniel Clarke
NOTE: Should probably be replaced with STL class.

Definition at line 33 of file btreebase.h.


Member Function Documentation

BTreeNode* BTreeBase::root (  )  const [inline]

Return a pointer to the root node of the tree

Definition at line 39 of file btreebase.h.

References m_root.

Referenced by Expression::compileConditional(), Expression::compileExpression(), Expression::processConstant(), pruneTree(), and setRoot().

void BTreeBase::setRoot ( BTreeNode root  )  [inline]

Set the root node of the tree

Definition at line 42 of file btreebase.h.

References m_root, and root().

Referenced by Expression::compileConditional(), Expression::compileExpression(), Expression::processConstant(), and replaceNode().

void BTreeBase::addNode ( BTreeNode parent,
BTreeNode node,
bool  left 
)

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

Definition at line 43 of file btreebase.cpp.

References BTreeNode::setLeft(), and BTreeNode::setRight().

void BTreeBase::deleteTree (  ) 

Deletes all nodes in tree and zeros pointer to root node

Definition at line 31 of file btreebase.cpp.

References BTreeNode::deleteChildren(), and m_root.

Referenced by ~BTreeBase().

void BTreeBase::pruneTree ( BTreeNode root,
bool  conditionalRoot = true 
)

Tidies the tree up; merging constants and removing redundant branches

Definition at line 49 of file btreebase.cpp.

References BTreeNode::childOp(), Traverser::current(), BTreeNode::deleteChildren(), Traverser::descendLeftwardToTerminal(), Parser::doArithmetic(), BTreeNode::hasChildren(), BTreeNode::left(), Traverser::moveToParent(), Traverser::oppositeNode(), BTreeNode::parent(), replaceNode(), BTreeNode::right(), root(), BTreeNode::setChildOp(), Traverser::setCurrent(), BTreeNode::setType(), BTreeNode::setValue(), BTreeNode::type(), and BTreeNode::value().

Referenced by Expression::compileConditional(), Expression::compileExpression(), and Expression::processConstant().

void BTreeBase::replaceNode ( BTreeNode node,
BTreeNode replacement 
)

Put a node in place of another, linking it correctly into the parent.

Definition at line 217 of file btreebase.cpp.

References BTreeNode::left(), BTreeNode::parent(), BTreeNode::right(), BTreeNode::setLeft(), BTreeNode::setParent(), BTreeNode::setRight(), and setRoot().

Referenced by pruneTree().


The documentation for this class was generated from the following files:
Generated on Tue May 8 17:05:34 2007 for KTechLab by  doxygen 1.5.1