Class Tree<TValue, TTree, TTreeNode>
- Namespace
- Garyon.DataStructures.Trees
- Assembly
- Garyon.dll
Represents a tree.
public abstract class Tree<TValue, TTree, TTreeNode> : BaseTree<TValue, TTree, TTreeNode>, ITree<TValue, TTree, TTreeNode>, ITree<TValue>, ICollection<TValue>, IEnumerable<TValue>, IEnumerable where TTree : Tree<TValue, TTree, TTreeNode> where TTreeNode : TreeNode<TValue, TTree, TTreeNode>
Type Parameters
TValueThe type of the elements the tree nodes store.
TTreeThe type of the tree that this type is used in.
TTreeNodeThe type of the tree nodes that are used in the
TTreetype.
- Inheritance
-
BaseTree<TValue, TTree, TTreeNode>Tree<TValue, TTree, TTreeNode>
- Implements
-
ITree<TValue, TTree, TTreeNode>ITree<TValue>ICollection<TValue>IEnumerable<TValue>
- Derived
-
Tree<T>
- Inherited Members
- Extension Methods
Constructors
Tree()
Initializes a new instance of the Tree<T> class with no root node.
public Tree()
Tree(TValue)
Initializes a new instance of the Tree<T> class with a root value.
public Tree(TValue rootValue)
Parameters
rootValueTValueThe value of the root node.
Tree(TTree)
Initializes a new instance of the Tree<T> class from a different tree.
public Tree(TTree tree)
Parameters
treeTTreeThe tree to create this tree from. Both trees remain independent.
Tree(TTreeNode)
Initializes a new instance of the Tree<T> class with a root node.
public Tree(TTreeNode root)
Parameters
rootTTreeNodeThe root node.
Methods
AddChild(TTreeNode, TValue, bool)
Adds a child to a node within this tree.
public void AddChild(TTreeNode node, TValue value, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to set. The node must be within this tree.
valueTValueThe value of the new child to add to the node.
propagateboolDetermines whether this function should propagate to the AddChild(TTreeNode) function. Only set this to false if the new child was already added before calling this function.
AddChild(TTreeNode, TTreeNode, bool)
Adds a child to a node within this tree.
public void AddChild(TTreeNode node, TTreeNode newChild, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to set. The node must be within this tree.
newChildTTreeNodeThe new child to add to the node.
propagateboolDetermines whether this function should propagate to the AddChild(TTreeNode) function. Only set this to false if the new child was already added before calling this function.
AddChildren(TTreeNode, IEnumerable<TTreeNode>, bool)
Adds children to a node within this tree.
public void AddChildren(TTreeNode node, IEnumerable<TTreeNode> newChildren, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to add. The node must be within this tree.
newChildrenIEnumerable<TTreeNode>The new children to add to the node.
propagateboolDetermines whether this function should propagate to the AddChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
ClearChildren(TTreeNode, bool)
Clears the children of a node within this tree.
public override void ClearChildren(TTreeNode node, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to clear. The node must be within this tree.
propagateboolDetermines whether this function should propagate to the Children property. Only set this to false if the new children are already set in the node before calling this function.
RemoveChildren(TValue, IEnumerable<TValue>, bool)
Removes children from a node within this tree.
public void RemoveChildren(TValue value, IEnumerable<TValue> childrenToRemove, bool propagate = true)
Parameters
valueTValueThe parent node whose children to add. The node must be within this tree.
childrenToRemoveIEnumerable<TValue>The children to remove from the node.
propagateboolDetermines whether this function should propagate to the RemoveChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
RemoveChildren(TValue, IEnumerable<TTreeNode>, bool)
Removes children from a node within this tree.
public void RemoveChildren(TValue value, IEnumerable<TTreeNode> childrenToRemove, bool propagate = true)
Parameters
valueTValueThe parent node whose children to add. The node must be within this tree.
childrenToRemoveIEnumerable<TTreeNode>The children to remove from the node.
propagateboolDetermines whether this function should propagate to the RemoveChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
RemoveChildren(TTreeNode, IEnumerable<TValue>, bool)
Removes children from a node within this tree.
public void RemoveChildren(TTreeNode node, IEnumerable<TValue> childrenToRemove, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to add. The node must be within this tree.
childrenToRemoveIEnumerable<TValue>The children to remove from the node.
propagateboolDetermines whether this function should propagate to the RemoveChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
RemoveChildren(TTreeNode, IEnumerable<TTreeNode>, bool)
Removes children from a node within this tree.
public void RemoveChildren(TTreeNode node, IEnumerable<TTreeNode> childrenToRemove, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to add. The node must be within this tree.
childrenToRemoveIEnumerable<TTreeNode>The children to remove from the node.
propagateboolDetermines whether this function should propagate to the RemoveChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
RemoveRootChildren(IEnumerable<TValue>, bool)
Removes this tree's root direct children.
public void RemoveRootChildren(IEnumerable<TValue> childrenToRemove, bool propagate = true)
Parameters
childrenToRemoveIEnumerable<TValue>The children to remove from the tree root node.
propagateboolDetermines whether this function should propagate to the RemoveChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
RemoveRootChildren(IEnumerable<TTreeNode>, bool)
Removes this tree's root direct children.
public void RemoveRootChildren(IEnumerable<TTreeNode> childrenToRemove, bool propagate = true)
Parameters
childrenToRemoveIEnumerable<TTreeNode>The children to remove from the tree root node.
propagateboolDetermines whether this function should propagate to the RemoveChildren(IEnumerable<TTreeNode>) function. Only set this to false if the new child was already added before calling this function.
SetChildren(TValue, IEnumerable<TValue>, bool)
Sets the children of a node within this tree.
public void SetChildren(TValue value, IEnumerable<TValue> newValues, bool propagate = true)
Parameters
valueTValueThe value of the parent node whose children to set. The node must be within this tree.
newValuesIEnumerable<TValue>The values of the new children to set to the node.
propagateboolDetermines whether this function should propagate to the Children property by setting the property to
newValues. Only set this to false if the new children are already set in the node before calling this function.
SetChildren(TValue, IEnumerable<TTreeNode>, bool)
Sets the children of a node within this tree.
public void SetChildren(TValue value, IEnumerable<TTreeNode> newChildren, bool propagate = true)
Parameters
valueTValueThe value of the parent node whose children to set. The node must be within this tree.
newChildrenIEnumerable<TTreeNode>The new children to set to the node.
propagateboolDetermines whether this function should propagate to the Children property by setting the property to
newChildren. Only set this to false if the new children are already set in the node before calling this function.
SetChildren(TValue, List<TTreeNode>, bool)
Sets the children of a node within this tree.
public void SetChildren(TValue value, List<TTreeNode> newChildren, bool propagate = true)
Parameters
valueTValueThe value of the parent node whose children to set. The node must be within this tree.
newChildrenList<TTreeNode>The new children to set to the node.
propagateboolDetermines whether this function should propagate to the Children property by setting the property to
newChildren. Only set this to false if the new children are already set in the node before calling this function.
SetChildren(TTreeNode, IEnumerable<TValue>, bool)
Sets the children of a node within this tree.
public void SetChildren(TTreeNode node, IEnumerable<TValue> newValues, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to set. The node must be within this tree.
newValuesIEnumerable<TValue>The values of the new children to set to the node.
propagateboolDetermines whether this function should propagate to the Children property by setting the property to
newValues. Only set this to false if the new children are already set in the node before calling this function.
SetChildren(TTreeNode, IEnumerable<TTreeNode>, bool)
Sets the children of a node within this tree.
public void SetChildren(TTreeNode node, IEnumerable<TTreeNode> newChildren, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to set. The node must be within this tree.
newChildrenIEnumerable<TTreeNode>The new children to set to the node.
propagateboolDetermines whether this function should propagate to the Children property by setting the property to
newChildren. Only set this to false if the new children are already set in the node before calling this function.
SetChildren(TTreeNode, List<TTreeNode>, bool)
Sets the children of a node within this tree.
public void SetChildren(TTreeNode node, List<TTreeNode> newChildren, bool propagate = true)
Parameters
nodeTTreeNodeThe parent node whose children to set. The node must be within this tree.
newChildrenList<TTreeNode>The new children to set to the node.
propagateboolDetermines whether this function should propagate to the Children property by setting the property to
newChildren. Only set this to false if the new children are already set in the node before calling this function.