23 #ifndef __UT_BIDIRECTIONALTREE_H__
24 #define __UT_BIDIRECTIONALTREE_H__
59 if (myParent == parent)
83 child->myParent =
this;
84 child->setNextSibling(myChildren);
96 if (child == myChildren)
97 myChildren = child->myNextSibling;
99 child->myParent = NULL;
100 old_prev = child->setPrevSibling(NULL);
101 old_next = child->setNextSibling(NULL);
103 (
void) old_prev->setNextSibling(old_next);
105 (
void) old_next->setPrevSibling(old_prev);
107 UT_ASSERT(myChildren == NULL || myChildren->myPrevSibling == NULL);
121 UT_ASSERT(myParent || (!myPrevSibling && !myNextSibling));
122 return (
T *)myParent;
126 return (
T *)myChildren;
130 return (
T *)myPrevSibling;
134 return (
T *)myNextSibling;
142 bool hasSiblings()
const {
return (myPrevSibling || myNextSibling); }
154 myNextSibling->myPrevSibling = NULL;
155 myNextSibling = next;
157 myNextSibling->myPrevSibling =
this;
166 myPrevSibling->myNextSibling = NULL;
167 myPrevSibling = prev;
169 myPrevSibling->myNextSibling =
this;
181 #endif // __UT_BIDIRECTIONALTREE_H__
UT_BidirectionalTree< T > NodeType
bool isInTree() const
Some utility methods.
T * getParent() const
Iterators.
void unlinkAll()
Unlink this node from the tree completely.
bool hasSiblings() const
Some utility methods.
bool hasChildren() const
Some utility methods.
T * getNextSibling() const
Iterators.
T * getPrevSibling() const
Iterators.
void removeAllChildren()
Remove all children from the tree.
T * getFirstChild() const
Iterators.
bool hasParent() const
Some utility methods.
void addChildToHead(NodeType *child)
Add a child node to the head of the children list. O(1)
void setParent(NodeType *parent)
void removeChild(NodeType *child)
Remove the given child node.
virtual ~UT_BidirectionalTree()