Class TreeNode<T>
Holds an associated Item of type T
for this TreeNode, with Children items that are all of type TreeNode<T>
Inherited Members
Namespace: LemonEdge.Utils
Assembly: Utils.dll
Syntax
public class TreeNode<T> : BaseTreeNode<T, TreeNode<T>>, ITreeNode<T, TreeNode<T>>, ITreeNode<T>, ITreeNode, IHasChildren<TreeNode<T>>, IHasChildren
Type Parameters
Name | Description |
---|---|
T | The type of the associated Item for this TreeNode |
Remarks
This TreeNode implements the BaseTreeNode<T, TN> where Type T
matches and TN is the TreeNode<T> itself to ensure all child items are of the same type again
Constructors
TreeNode(T)
Creates a new TreeNode with the specified item as the associated Item of type T
for this TreeNode
Declaration
public TreeNode(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The associated Item of type |
TreeNode(T, TreeNode<T>)
Creates a new TreeNode with the specified item as the associated Item of type T
, along with the specified parent TreeNode
Declaration
public TreeNode(T item, TreeNode<T> parent)
Parameters
Type | Name | Description |
---|---|---|
T | item | The associated Item of type |
TreeNode<T> | parent | The parent TreeNode<T> of this TreeNode |
TreeNode(Func<TreeNode<T>, Int32>, T)
Creates a new TreeNode with the specified item as the associated Item of type T
, along with an associated function for the order of all the Children items
Declaration
public TreeNode(Func<TreeNode<T>, int> getOrder, T item)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TreeNode<T>, System.Int32> | getOrder | A function specifying the order for each child item |
T | item | The associated Item of type |
TreeNode(Func<TreeNode<T>, Int32>, T, TreeNode<T>)
Creates a new TreeNode with the specified item as the associated Item of type T
, along with an associated function for the order of all the Children items, and the specified parent TreeNode
Declaration
public TreeNode(Func<TreeNode<T>, int> getOrder, T item, TreeNode<T> parent)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TreeNode<T>, System.Int32> | getOrder | A function specifying the order for each child item |
T | item | The associated Item of type |
TreeNode<T> | parent | The parent TreeNode<T> of this TreeNode |
Methods
CreateNewItem(T, TreeNode<T>)
Declaration
protected override TreeNode<T> CreateNewItem(T item, TreeNode<T> parent)
Parameters
Type | Name | Description |
---|---|---|
T | item | |
TreeNode<T> | parent |
Returns
Type | Description |
---|---|
TreeNode<T> |
Overrides
CreateTree(IEnumerable<T>, Func<T, T>)
Creates a TreeNode for each item in allItems
collection, returns only the top level nodes with the rest as children in the correct treenode structure
Declaration
public static IEnumerable<TreeNode<T>> CreateTree(IEnumerable<T> allItems, Func<T, T> getParent)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | allItems | A list of items to each be wrapped in a TreeNode<T> |
System.Func<T, T> | getParent | A function specifying the parent item in the |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TreeNode<T>> | A collection of TreeNode<T> that are the root items (those with no parent as indicated by the |