SubcloneSeeker  1.0.0
Subclone deconvolution software framework
 All Classes Files Functions Variables Macros Pages
SubcloneSeeker::TreeNode Class Reference

Base class for any object that can seve as a tree node. More...

#include <TreeNode.h>

Inheritance diagram for SubcloneSeeker::TreeNode:
SubcloneSeeker::Subclone

Public Member Functions

 TreeNode ()
 
virtual ~TreeNode ()
 
TreeNodeVec_t & getVecChildren ()
 
TreeNodegetParent ()
 
void addChild (TreeNode *child)
 
void removeChild (TreeNode *child)
 
bool isLeaf () const
 
bool isRoot () const
 

Static Public Member Functions

static void PreOrderTraverse (TreeNode *root, TreeTraverseDelegate &traverseDelegate)
 
static void PostOrderTraverse (TreeNode *root, TreeTraverseDelegate &traverseDelegate)
 

Protected Attributes

TreeNodeVec_t children
 
TreeNodeparent
 

Friends

class TreeTraverseDelegate
 

Detailed Description

Base class for any object that can seve as a tree node.

This class implements the basic tree operations, such as adding and removing children nodes, checking whether self is a root or a leaf, etc. It also implements, as class method, two basic traversing algorithm: . PreOrderTraverse . PostOrderTraverse Since the tree is not required to be binary, InOrder traverse makes little sense.

Constructor & Destructor Documentation

SubcloneSeeker::TreeNode::TreeNode ( )
inline

minimal constructor, reset all member variables

virtual SubcloneSeeker::TreeNode::~TreeNode ( )
inlinevirtual

declaring destructor to be virtual

Member Function Documentation

void TreeNode::addChild ( TreeNode child)

append a given node to this node's children list

Parameters
childA pointer to the node which which will be added as a child
TreeNode* SubcloneSeeker::TreeNode::getParent ( )
inline

returns the node's parent.

Returns
parent node's address, or NULL if called on a root node
TreeNodeVec_t& SubcloneSeeker::TreeNode::getVecChildren ( )
inline

returns a reference to the children vector

Returns
A std::vector of children node pointers
bool SubcloneSeeker::TreeNode::isLeaf ( ) const
inline

whether the node is a leaf node

Returns
whether the node is a leaf node
bool SubcloneSeeker::TreeNode::isRoot ( ) const
inline

whether the node is a root node

Returns
whether the node is a root node
void TreeNode::PostOrderTraverse ( TreeNode root,
TreeTraverseDelegate traverseDelegate 
)
static

Post-Order traverse algorithm

This method process the root node first, then all the children nodes (recursively), The actual action performed on the nodes are defined by the TreeTraverseDelegate object

Parameters
rootThe root node of the (sub)tree the traversing takes place
traverseDelegateAn TreeTraverseDelegate object which defines the action performed on nodes
void TreeNode::PreOrderTraverse ( TreeNode root,
TreeTraverseDelegate traverseDelegate 
)
static

Pre-Order traverse algorithm

This method process all the children nodes first (recursively), and then process the root. The actual action performed on the nodes are defined by the TreeTraverseDelegate object

Parameters
rootThe root node of the (sub)tree the traversing takes place
traverseDelegateAn TreeTraverseDelegate object which defines the action performed on nodes
void TreeNode::removeChild ( TreeNode child)

remove a child of this node

Parameters
childA pointer to the children node to be removed

Member Data Documentation

TreeNodeVec_t SubcloneSeeker::TreeNode::children
protected

children node list

TreeNode* SubcloneSeeker::TreeNode::parent
protected

parent node


The documentation for this class was generated from the following files: