StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Attributes | List of all members
StiTreeNode Class Reference

#include <StiTreeNode.h>

Inheritance diagram for StiTreeNode:
StiTrackNode StiKalmanTrackNode

Public Member Functions

 StiTreeNode ()
const StiTreeNodeoperator= (const StiTreeNode &node)
void reset ()
void unset ()
void remove (int childIndex)
StiTreeNodedisconnect (int all=0)
void cutTail (int direction)
void setParent (StiTreeNode *newParent)
StiTreeNodegetParent () const
StiTreeNodegetChildAt (int index) const
int getChildCount () const
void add (StiTreeNode *newChild, int direction)
StiTreeNodegetNextNode () const
 Returns the node that follows this node in a preorder traversal of this.
StiTreeNodegetPrevNode () const
StiTreeNodegetFirstNode () const
StiTreeNodegetLastNode () const
void remove (StiTreeNode **fstNode, StiTreeNode **lstNode)

Protected Attributes

StiTreeNodechildren [2]

Detailed Description

A StiTreeNode is a general-purpose node in a tree data structure. A tree node may have at most one parent and 0 or more children. StiTreeNode provides operations for examining and modifying a node's parent and children and also operations for examining the tree that the node is a part of. A node's tree is the set of all nodes that can be reached by starting at the node and following all the possible links to parents and children. A node with no parent is the root of its tree; a node with no children is a leaf. A tree may consist of many subtrees, each node acting as the root for its own subtree.

This class provides enumerations for efficiently traversing a tree or subtree in various orders or for following the path between two nodes.

This is not a thread safe class.If you intend to use a StiDefaultMutableTreeNode (or a tree of TreeNodes) in more than one thread, you need to do your own synchronizing. A good convention to adopt is synchronizing on the root node of a tree.

While StiDefaultMutableTreeNode implements the MutableTreeNode interface and will allow you to add in any implementation of MutableTreeNode not all of the methods in StiDefaultMutableTreeNode will be applicable to all StiTreeNodes implementations. Especially with some of the enumerations that are provided, using some of these methods assumes the StiDefaultMutableTreeNode contains only StiDefaultMutableNode instances. All of the TreeNode/MutableTreeNode methods will behave as defined no matter what implementations are added.

See Also
Claude Pruneau

Definition at line 47 of file StiTreeNode.h.

Constructor & Destructor Documentation

StiTreeNode::StiTreeNode ( )

Creates a tree node that has no parent and no children, but which allows children.

Definition at line 9 of file StiTreeNode.cxx.

Member Function Documentation

StiTreeNode * StiTreeNode::getChildAt ( int  index) const

Returns the child at the specified index in this node's child array.

indexan index into this node's child array is out of bounds
the StiTreeNode in this node's child array at the specified index

Definition at line 93 of file StiTreeNode.cxx.

int StiTreeNode::getChildCount ( ) const

Returns the number of children of this node.

an int giving the number of children of this node

Definition at line 103 of file StiTreeNode.cxx.

StiTreeNode * StiTreeNode::getParent ( ) const

Returns this node's parent or 0 if this node has no parent.

this node's parent TreeNode, or 0 if this node has no parent

Definition at line 83 of file StiTreeNode.cxx.

void StiTreeNode::remove ( int  childIndex)

Removes the child at the specified index from this node's children and sets that node's parent to 0. The child node to remove must be a StiTreeNode *.

childIndexthe index in this node's child array of the child to remove
ArrayIndexOutOfBoundsExceptionif childIndex is out of bounds

Definition at line 28 of file StiTreeNode.cxx.

References BFactory::Free(), and remove().

Referenced by remove().

void StiTreeNode::setParent ( StiTreeNode newParent)

Sets this node's parent to newParent but does not change the parent's child array. This method is called from insert() and remove() to reassign a child's parent, it should not be messaged from anywhere else.

newParentthis node's new parent

Definition at line 73 of file StiTreeNode.cxx.

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