public class MTBTree extends Object implements Cloneable
The main component of a tree is its root node. It can have an unrestricted number of children. The tree structure is implicitly given by the recursive (one-way) linkage of nodes to their children. Each node of the tree is associated with a certain data object. Each data object has to be derived from class 'TreeNodeData' to enable one of the basic features of this tree - the recursive printing of data contained within the tree.
MTBTreeNode,
MTBTreeNodeData| Modifier and Type | Field and Description |
|---|---|
protected MTBTreeNode |
root
Root node of the tree.
|
| Constructor and Description |
|---|
MTBTree(MTBTreeNode rootNode)
Constructor for the tree for a given root node.
|
MTBTree(MTBTreeNodeData rootObject)
Constructor for the tree.
|
| Modifier and Type | Method and Description |
|---|---|
MTBTree |
clone() |
protected static void |
cloneChild(MTBTreeNode np,
MTBTreeNode c)
Helper function to recursively clone child nodes in a deep fashion.
|
Vector<MTBTreeNode> |
getAllNodesDepthFirst()
Get all nodes in a depth-first sorting.
|
MTBTreeNode |
getRoot()
Access the root node.
|
void |
printTree()
Prints tree data.
|
protected MTBTreeNode root
public MTBTree(MTBTreeNodeData rootObject)
An associated data object has to be provided in any case.
rootObject - Data object associated with the root node.public MTBTree(MTBTreeNode rootNode)
rootNode - the root nodeprotected static void cloneChild(MTBTreeNode np, MTBTreeNode c)
np - Parent node to which the clone of the child should be added.c - Current child node to be cloned.public MTBTreeNode getRoot()
public void printTree()
Special feature of this tree: this function prints recursively the data contained inside the tree. Prerequisite for this is that the data objects of each node provide a method for printing their data in a reasonable way, i.e. implement the method printData() of the abstract class TreeNodeData.
public Vector<MTBTreeNode> getAllNodesDepthFirst()
Copyright © 2010–2025 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.