Table of Contents

Interface ITreeNode<TValue>

Namespace
Garyon.DataStructures.Trees
Assembly
Garyon.dll

Represents a tree node, which is a component that is contained within a tree.

public interface ITreeNode<TValue> : IEnumerable<TValue>, IEnumerable

Type Parameters

TValue

The type of the value that is stored in the node.

Inherited Members
Extension Methods

Properties

BaseTreeHeight

Gets the height of this tree node's base tree height. It is equal to the sum of this tree node's height and depth. Prefer calling this instead of the Height property on Root.

int BaseTreeHeight { get; }

Property Value

int

Breadth

Gets the breadth of this tree node.

int Breadth { get; }

Property Value

int

ChildrenCount

Gets the count of children of this node; prefer calling this property instead of getting the count directly from the respective property to retrieve the children.

int ChildrenCount { get; }

Property Value

int

Depth

Gets the depth of this tree node.

int Depth { get; }

Property Value

int

Descendants

Gets the descendants of this tree node.

int Descendants { get; }

Property Value

int

Height

Gets the height of this tree node's subtree.

int Height { get; }

Property Value

int

IsLeaf

Determines whether this node is a leaf; that is, it has no children.

bool IsLeaf { get; }

Property Value

bool

IsRoot

Determines whether this node is the root; that is, its parent is null.

bool IsRoot { get; }

Property Value

bool

Value

The value of the node.

TValue Value { get; set; }

Property Value

TValue

Methods

GetTreeView(int)

Gets the tree view of this tree node as a subtree.

string GetTreeView(int childIndent = 4)

Parameters

childIndent int

The length of the indentation for each subsequent child.

Returns

string

The tree view.

RemoveChild(TValue)

Removes a child from this node's children list.

bool RemoveChild(TValue childToRemove)

Parameters

childToRemove TValue

The child to remove from this node's children list.

Returns

bool

RemoveNode(TValue)

Removes a node that has the specified value. This includes any node that is within the subtree with this tree node as the root.

bool RemoveNode(TValue value)

Parameters

value TValue

The value of the node to remove from this node's children list.

Returns

bool

true if the child was successfully removed from this node's children list, otherwise false.

RemoveNodes(IEnumerable<TValue>)

Removes nodes that have the specified values. This includes any node that is within the subtree with this tree node as the root.

void RemoveNodes(IEnumerable<TValue> values)

Parameters

values IEnumerable<TValue>

The values of the child nodes to remove from this node's children list.

RemoveNodes(params TValue[])

Removes nodes that have the specified values. This includes any node that is within the subtree with this tree node as the root.

void RemoveNodes(params TValue[] values)

Parameters

values TValue[]

The values of the child nodes to remove from this node's children list.

TraverseLevelOrder()

Traverses the subtree with this node as a root using level-order.

IEnumerable<TValue> TraverseLevelOrder()

Returns

IEnumerable<TValue>

An IEnumerable<T> containing the yielded values.

TraversePostOrder()

Traverses the subtree with this node as a root using post-order.

IEnumerable<TValue> TraversePostOrder()

Returns

IEnumerable<TValue>

An IEnumerable<T> containing the yielded values.

TraversePreOrder()

Traverses the subtree with this node as a root using pre-order.

IEnumerable<TValue> TraversePreOrder()

Returns

IEnumerable<TValue>

An IEnumerable<T> containing the yielded values.