StRoot
1
|
#include <StiTreeNode.h>
Public Member Functions | |
StiTreeNode () | |
const StiTreeNode & | operator= (const StiTreeNode &node) |
void | reset () |
void | unset () |
void | remove (int childIndex) |
StiTreeNode * | disconnect (int all=0) |
void | cutTail (int direction) |
void | setParent (StiTreeNode *newParent) |
StiTreeNode * | getParent () const |
StiTreeNode * | getChildAt (int index) const |
int | getChildCount () const |
void | add (StiTreeNode *newChild, int direction) |
StiTreeNode * | getNextNode () const |
Returns the node that follows this node in a preorder traversal of this. | |
StiTreeNode * | getPrevNode () const |
StiTreeNode * | getFirstNode () const |
StiTreeNode * | getLastNode () const |
void | remove (StiTreeNode **fstNode, StiTreeNode **lstNode) |
Protected Attributes | |
StiTreeNode * | parent |
StiTreeNode * | children [2] |
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.
Definition at line 47 of file StiTreeNode.h.
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.
StiTreeNode * StiTreeNode::getChildAt | ( | int | index | ) | const |
Returns the child at the specified index in this node's child array.
index | an index into this node's child array is out of bounds |
Definition at line 93 of file StiTreeNode.cxx.
int StiTreeNode::getChildCount | ( | ) | const |
Returns 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.
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 *
.
childIndex | the index in this node's child array of the child to remove |
ArrayIndexOutOfBoundsException | if 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.
newParent | this node's new parent |
Definition at line 73 of file StiTreeNode.cxx.