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
TValueThe 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
Breadth
Gets the breadth of this tree node.
int Breadth { get; }
Property Value
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
Depth
Gets the depth of this tree node.
int Depth { get; }
Property Value
Descendants
Gets the descendants of this tree node.
int Descendants { get; }
Property Value
Height
Gets the height of this tree node's subtree.
int Height { get; }
Property Value
IsLeaf
Determines whether this node is a leaf; that is, it has no children.
bool IsLeaf { get; }
Property Value
IsRoot
Determines whether this node is the root; that is, its parent is null.
bool IsRoot { get; }
Property Value
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
childIndentintThe 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
childToRemoveTValueThe child to remove from this node's children list.
Returns
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
valueTValueThe value of the node to remove from this node's children list.
Returns
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
valuesIEnumerable<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
valuesTValue[]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.