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
TValueThe type of the value that is stored in the node.
TTreeThe type of the tree that this type is used in.
TTreeNodeThe type of the tree nodes that are used in the
TTreetype.
- 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 originalTTreeNode's base tree.
GetChild(TValue)
Gets a direct child of this node that has the specified value.
TTreeNode GetChild(TValue value)
Parameters
valueTValueThe value of the direct child node to find.
Returns
- TTreeNode
The
TTreeNodewith 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
valueTValueThe value of the tree node to find.
Returns
- TTreeNode
The
TTreeNodewith the specified value, if found; otherwise false.
MakeChildOf(TTreeNode)
Makes this node a child of another tree node.
void MakeChildOf(TTreeNode other)
Parameters
otherTTreeNodeThe 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
otherTTreeNodeThe 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
childToRemoveTTreeNodeThe child to remove from this node's children list.
Returns
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
nodeTTreeNodeThe node to remove from this node's children list.
Returns
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.