Table of Contents

Interface ITreeNode<TValue, TTree, TTreeNode>

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, TTree, TTreeNode> : ITreeNode<TValue>, IEnumerable<TValue>, IEnumerable where TTree : ITree<TValue, TTree, TTreeNode> where TTreeNode : ITreeNode<TValue, TTree, TTreeNode>

Type Parameters

TValue

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

TTree

The type of the tree that this type is used in.

TTreeNode

The type of the tree nodes that are used in the TTree type.

Inherited Members
Extension Methods

Properties

BaseTree

Gets or sets the base tree that contains this node.

TTree BaseTree { get; set; }

Property Value

TTree

Children

Gets or sets the children nodes of this tree.

List<TTreeNode> Children { get; set; }

Property Value

List<TTreeNode>

The new list of nodes to set the children to.

Parent

Gets or sets the parent node of this tree node.

TTreeNode Parent { get; set; }

Property Value

TTreeNode

Methods

Clone()

Clones this TTreeNode and all its children recursively.

TTreeNode Clone()

Returns

TTreeNode

The cloned TTreeNode. Its base tree is also equal to the original TTreeNode's base tree.

GetChild(TValue)

Gets a direct child of this node that has the specified value.

TTreeNode GetChild(TValue value)

Parameters

value TValue

The value of the direct child node to find.

Returns

TTreeNode

The TTreeNode with the specified value, if found; otherwise false.

GetNode(TValue)

Gets a node from the subtree with this tree node as a root node that has the specified value.

TTreeNode GetNode(TValue value)

Parameters

value TValue

The value of the tree node to find.

Returns

TTreeNode

The TTreeNode with the specified value, if found; otherwise false.

MakeChildOf(TTreeNode)

Makes this node a child of another tree node.

void MakeChildOf(TTreeNode other)

Parameters

other TTreeNode

The other tree node that will become this node's parent.

MakeParentOf(TTreeNode)

Makes this node a parent of another tree node.

void MakeParentOf(TTreeNode other)

Parameters

other TTreeNode

The other tree node that will become this node's child.

RemoveChild(TTreeNode)

Removes a child from this node's children list.

bool RemoveChild(TTreeNode childToRemove)

Parameters

childToRemove TTreeNode

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

Returns

bool

RemoveNode(TTreeNode)

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(TTreeNode node)

Parameters

node TTreeNode

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.

TraverseLevelOrderNodes()

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

IEnumerable<TTreeNode> TraverseLevelOrderNodes()

Returns

IEnumerable<TTreeNode>

An IEnumerable<T> containing the yielded nodes.

TraversePostOrderNodes()

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

IEnumerable<TTreeNode> TraversePostOrderNodes()

Returns

IEnumerable<TTreeNode>

An IEnumerable<T> containing the yielded nodes.

TraversePreOrderNodes()

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

IEnumerable<TTreeNode> TraversePreOrderNodes()

Returns

IEnumerable<TTreeNode>

An IEnumerable<T> containing the yielded nodes.