2 #include "StiTreeNode.h"
14 void StiTreeNode::reset()
16 parent = 0; children[0]=0; children[1]=0;
32 node =children[childIndex];children[childIndex]=0;
33 if (!childIndex) {children[0]=children[1]; children[1]=0;}
35 if (node->parent!=
this)
return;
39 node = parent; parent=0;
52 node = parent; parent=0;
54 assert(node->children[0]==
this);
58 node->children[0]=children[0];
59 if (children[0]) children[0]->parent=node;
95 return children[index];
145 parent = node.parent;
149 void StiTreeNode::add(
StiTreeNode * newChild,
int direction)
152 assert(!children[1]);
153 children[1]=children[0];
154 children[0]=newChild;
161 newChild->children[0]=
this;
162 newChild->children[1]=0;
181 while ((back = node->getPrevNode())) {
188 void StiTreeNode::cutTail(
int direction)
190 direction = (direction)? -1:0;
196 assert(!children[1]);
197 StiTreeNode **kLeft = (parent )? &parent->children[0]:fstNode;
198 StiTreeNode **kRite = (children[0])? &children[0]->parent:lstNode;
199 *kLeft = children[0];
void setParent(StiTreeNode *newParent)
StiTreeNode * getNextNode() const
Returns the node that follows this node in a preorder traversal of this.
StiTreeNode * getChildAt(int index) const
StiTreeNode * getParent() const
int getChildCount() const
static void Free(void *obj)
Free an object for reuse.
void remove(int childIndex)