Name

Class xbTreeNode — provide simple tree data structure

Synopsis

extends Class xbObject

class xbTreeNode : xbObject
 {
   xbTreeNode();
   
   // methods
   void init();
   void destory();
   xbTreeNode appendChild(xbTreeNode newChild);
   xbTreeNode insertBefore(xbTreeNode newChild, xbTreeNode refChild);
   xbTreeNode removeChild(xbTreeNode oldChild);
   xbTreeNode replaceChild(xbTreeNode newChild, xbTreeNode oldChild);
   xbTreeNode getRoot();
   
   // properties
   xbTreeNode parentNode;
   xbTreeNode firstChild;
   xbTreeNode lastChild;
   xbArray    childNodes;
   xbTreeNode previousSibling;
   xbTreeNode nextSibling;
}
		

Description

xbTreeNode is a simple tree data structure based loosely on the DOM Level 2 Node interface. It is intended to provide a non-DOM related tree data structure.

Properties

parentNode

readonly xbTreeNode - parent of current xbTreeNode

firstChild

readonly xbTreeNode - first child of current xbTreeNode.

lastChild

readonly xbTreeNode - last child of current xbTreeNode.

childNodes

readonly xbArray - list of children of current xbTreeNode.

previousSibling

readonly xbTreeNode - previous Sibling of current xbTreeNode.

nextSibling

readonly xbTreeNode - next Sibling of current xbTreeNode.

Methods

xbTreeNode()

Constructs an instance of the xbTreeNode class.

Returns. Nothing

Exceptions

  • None

appendChild(xbTreeNode newChild)

Append the newChild xbTreeNode to the end of this node's children and return a reference of the new node. If newChild already is part of a tree, it is first removed from the tree.

Returns.  xbTreeNode newChild

Exceptions

  • None

insertBefore(xbTreeNode newChild, xbTreeNode refChild)

Insert newChild xbTreeNode into this node's children before the refChild and return a reference to the new node. If refChild is null, then newChild is appended. If newChild already is part of a tree, it is first removed from the tree.

Returns.  xbTreeNode newChild

Exceptions

  • xbException: Not found

removeChild(xbTreeNode oldChild)

Remove the oldChild from it's tree and return a reference to it.

Returns.  xbTreeNode oldChild

Exceptions

  • xbException: Not found

replaceChild(xbTreeNode newChild, xbTreeNode oldChild)

Replace oldChild with newChild and return a reference to the old node.

Returns.  xbTreeNode oldChild

Exceptions

  • None

getRoot()

Return the root of the tree that this node belongs to.

Returns.  xbTreeNode root of xbTreeNode tree this xbTreeNode belongs to.

Exceptions

  • None