GeneralTree
A tree in which element can have either zero or many children. This structure is link-based.
length
/**
* Number of elements in the tree.
*
* @readonly
*/
get length(): numberaddChild()
/**
* Adds child element to parent element at the specified position.
*
* @param position Position of the parent element.
* @param element Element to add.
* @returns Position of the added element.
*/
addChild(position: Position<T, Node<T>>, element: T): Position<T, Node<T>>addRoot()
/**
* Adds the specified element at the root of the tree. Throws an error if the tree is not empty.
*
* @param element Element to add.
* @returns Position of the added element.
*/
addRoot(element: T): Position<T, Node<T>>areEqual()
attach()
clear()
getChildren()
getNumChildren()
getDepth()
getHeight()
getParent()
getRoot()
isEmpty()
isLeaf()
isRoot()
remove()
replace()
traverse()
Last updated
Was this helpful?