Table of Contents

Interface ITree<TValue, TTree, TTreeNode>

Namespace
Garyon.DataStructures.Trees
Assembly
Garyon.dll

Represents a tree.

public interface ITree<TValue, TTree, TTreeNode> : ITree<TValue>, ICollection<TValue>, IEnumerable<TValue>, IEnumerable where TTree : ITree<TValue, TTree, TTreeNode> where TTreeNode : ITreeNode<TValue, TTree, TTreeNode>

Type Parameters

TValue

The type of the elements the tree nodes store.

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

Root

Gets or sets the root node.

TTreeNode Root { get; set; }

Property Value

TTreeNode

Methods

ClearChildren(TTreeNode)

Clears the children of a node within this tree.

void ClearChildren(TTreeNode node)

Parameters

node TTreeNode

The parent node whose children to clear. The node must be within this tree.

GetNode(TValue)

Gets a child node within this tree that has the specified value.

TTreeNode GetNode(TValue value)

Parameters

value TValue

The value of the child tree node to find.

Returns

TTreeNode

The TreeNode<T> with the specified value, if found; otherwise false.

RemoveNode(TTreeNode)

Removes a child within this tree.

bool RemoveNode(TTreeNode childToRemove)

Parameters

childToRemove TTreeNode

The child to remove from the node.

Returns

bool

true if the node was successfully removed, otherwise false.

RemoveNodes(TTreeNode, IEnumerable<TValue>)

Removes nodes within a subtree with root as the specified node that contain the specified values.

void RemoveNodes(TTreeNode node, IEnumerable<TValue> values)

Parameters

node TTreeNode

The node which is the root of the subtree in which to remove the nodes at.

values IEnumerable<TValue>

The values of the children to remove.

TraverseLevelOrderNodes()

Traverses the tree from the root using level-order.

IEnumerable<TTreeNode> TraverseLevelOrderNodes()

Returns

IEnumerable<TTreeNode>

An IEnumerable<T> containing the yielded nodes.

TraversePostOrderNodes()

Traverses the tree from the root using post-order.

IEnumerable<TTreeNode> TraversePostOrderNodes()

Returns

IEnumerable<TTreeNode>

An IEnumerable<T> containing the yielded nodes.

TraversePreOrderNodes()

Traverses the tree from the root using pre-order.

IEnumerable<TTreeNode> TraversePreOrderNodes()

Returns

IEnumerable<TTreeNode>

An IEnumerable<T> containing the yielded nodes.