Interface ITreeNode<T>
Interface representing a tree node.
Inherited Members
Namespace:Extend
Assembly:Extend.dll
Syntax
public interface ITreeNode<T> : IDisposable, IEnumerable<ITreeNode<T>>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The type of the node's value. |
Properties
| Improve this Doc View SourceAncestorsTraversalDirection
Gets or sets the ancestors traversal direction.
Declaration
TreeTraversalDirection AncestorsTraversalDirection { get; set; }
Property Value
Type | Description |
---|---|
TreeTraversalDirection | The ancestors traversal direction. |
Children
Gets the children of the node.
Declaration
ITreeNodeCollection<T> Children { get; set; }
Property Value
Type | Description |
---|---|
ITreeNodeCollection<T><T> | The children of the node. |
Depth
Gets the depth of the node.
Declaration
int Depth { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The depth of the node. |
Descendants
Gets an enumeration of all tree nodes which are below the current node in the tree.
Declaration
IEnumerable<ITreeNode<T>> Descendants { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>> | An enumeration of all tree nodes which are below the current node in the tree. |
DescendantsTraversalDirection
Gets or sets the descendants traversal direction.
Declaration
TreeTraversalDirection DescendantsTraversalDirection { get; set; }
Property Value
Type | Description |
---|---|
TreeTraversalDirection | The descendants traversal direction. |
DisposeTraversalDirection
Gets or sets the dispose traversal direction.
Declaration
TreeTraversalDirection DisposeTraversalDirection { get; set; }
Property Value
Type | Description |
---|---|
TreeTraversalDirection | The dispose traversal direction. |
HasChildren
Gets a value indicating whether the node has any children or not.
Declaration
bool HasChildren { get; }
Property Value
Type | Description |
---|---|
System.Boolean | A value indicating whether the node has any children or not. |
HasParent
Gets a value indicating whether the node has a parent or not.
Declaration
bool HasParent { get; }
Property Value
Type | Description |
---|---|
System.Boolean | A value indicating whether the node has a parent or not. |
Parent
Gets or sets the parent of the node.
Declaration
ITreeNode<T> Parent { get; set; }
Property Value
Type | Description |
---|---|
ITreeNode<T><T> | The parent of the node. |
Root
Gets the root of the tree.
Declaration
ITreeNode<T> Root { get; }
Property Value
Type | Description |
---|---|
ITreeNode<T><T> | The root of the tree. |
SearchTraversalDirection
Gets or sets the search traversal direction.
Declaration
TreeTraversalDirection SearchTraversalDirection { get; set; }
Property Value
Type | Description |
---|---|
TreeTraversalDirection | The search traversal direction. |
TraversalDirection
Gets or sets the traversal direction used to enumerate the nodes.
Declaration
TreeTraversalDirection TraversalDirection { get; set; }
Property Value
Type | Description |
---|---|
TreeTraversalDirection | The traversal direction used to enumerate the nodes. |
Value
Gets or sets the value of the node.
Declaration
T Value { get; set; }
Property Value
Type | Description |
---|---|
T | The value of the node. |
Methods
| Improve this Doc View SourceAdd(T)
Adds the given value as child to the node.
Declaration
ITreeNode<T> Add(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to add. |
Returns
Type | Description |
---|---|
ITreeNode<T><T> | Returns the added node. |
Add(ITreeNode<T>)
Adds the given node as child to the node, if it is not already a child of the node.
Declaration
ITreeNode<T> Add(ITreeNode<T> node)
Parameters
Type | Name | Description |
---|---|---|
ITreeNode<T><T> | node | The node to add. |
Returns
Type | Description |
---|---|
ITreeNode<T><T> | Returns the added node. |
FindNode(T)
Gets the nodes with the given value.
Declaration
IEnumerable<ITreeNode<T>> FindNode(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to search. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>> | Returns the nodes with the given value. |
FindNode(Func<ITreeNode<T>, Boolean>)
Gets the nodes which matches the given predicate.
Declaration
IEnumerable<ITreeNode<T>> FindNode(Func<ITreeNode<T>, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><ITreeNode<T><T>, System.Boolean> | predicate | The predicate. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><ITreeNode<T><T>> | Returns the nodes which matches the given predicate. |
Remarks
Starts the search at the current tree node and traverses down the tree (Direction based on
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | predicate can not be null. |
FindValue(Func<ITreeNode<T>, Boolean>)
Gets the values which matches the given predicate.
Declaration
IEnumerable<T> FindValue(Func<ITreeNode<T>, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, TResult><ITreeNode<T><T>, System.Boolean> | predicate | The predicate. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><T> | Returns the values which matches the given predicate. |
Remarks
Starts the search at the current tree node and traverses down the tree (Direction based on
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | predicate can not be null. |
SetAllDirections(TreeTraversalDirection)
Sets all directions (DisposeTraversalDirection, SearchTraversalDirection,
AncestorsTraversalDirection, DescendantsTraversalDirection).
Declaration
void SetAllDirections(TreeTraversalDirection direction)
Parameters
Type | Name | Description |
---|---|---|
TreeTraversalDirection | direction | The new direction. |
SetParent(ITreeNode<T>, Boolean, Boolean)
Sets the parent of the tree node.
Declaration
void SetParent(ITreeNode<T> parent, bool attacheToNewParent = true, bool detachFromOldParent = true)
Parameters
Type | Name | Description |
---|---|---|
ITreeNode<T><T> | parent | The new parent. |
System.Boolean | attacheToNewParent | A value determining whether the node should add it self to the children of the new parent or not. |
System.Boolean | detachFromOldParent | A value indicating whether the node should detach itself from it's old parent or not. |
Remarks
TODO: add test for detachFromOldParent