@studyportals/sp-hs-misc
Version:
Miscellaneous code used in HouseStark's projects
41 lines (40 loc) • 957 B
TypeScript
/**
* A tree node.
*/
declare class TreeNode<T> {
private _parent;
private _children;
/**
* Gets or sets the node's content.
*/
content: T;
/**
* Initializes a new TreeNode<T> instance.
*
* @param parent The node's parent.
*/
constructor(parent?: TreeNode<T> | null);
/**
* Gets the node's parent.
*/
get parent(): TreeNode<T> | null;
/**
* Gets the node's children.
*/
get children(): Array<TreeNode<T>>;
/**
* Adds the specified node to the current node's children collection.
*
* @param child The node that is to be appended to the current node's children collection.
*/
addChild(child: TreeNode<T>): void;
/**
* Gets a value that specifies whether the node is a root.
*/
isRoot(): boolean;
/**
* Gets a value that specifies whether the node is a leaf.
*/
isLeaf(): boolean;
}
export { TreeNode };