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: LemonEdge.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(Func<TreeNode<T>, int>, 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 |
---|---|---|
Func<TreeNode<T>, int> | getOrder | A function specifying the order for each child item |
T | item | The associated Item of type |
TreeNode(Func<TreeNode<T>, int>, 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 |
---|---|---|
Func<TreeNode<T>, int> | 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 |
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 |
Methods
CreateNewItem(T, TreeNode<T>)
Used to create a new instance of this treenode type
Declaration
protected override TreeNode<T> CreateNewItem(T item, TreeNode<T> parent)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be wrapped in a treenode |
TreeNode<T> | parent | Any parent treenode for this item |
Returns
Type | Description |
---|---|
TreeNode<T> | A new treenode with the specified |
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 |
---|---|---|
IEnumerable<T> | allItems | A list of items to each be wrapped in a TreeNode<T> |
Func<T, T> | getParent | A function specifying the parent item in the |
Returns
Type | Description |
---|---|
IEnumerable<TreeNode<T>> | A collection of TreeNode<T> that are the root items (those with no parent as indicated by the
|