Class NTree<T>
- Namespace
- SunamoData.Data
- Assembly
- SunamoData.dll
Represents a node in an N-ary tree structure.
public class NTree<T>
Type Parameters
TThe type of data stored in each node.
- Inheritance
-
NTree<T>
- Inherited Members
- Extension Methods
Constructors
NTree(T)
Initializes a new instance of the NTree<T> class with the specified data.
public NTree(T data)
Parameters
dataTThe data to store in this node.
Properties
Children
Gets or sets the collection of child nodes.
public LinkedList<NTree<T>> Children { get; set; }
Property Value
- LinkedList<NTree<T>>
Data
Gets or sets the data stored in this node.
public T Data { get; set; }
Property Value
- T
Methods
AddChild(T)
Adds a new child node with the specified data.
public NTree<T> AddChild(T data)
Parameters
dataTThe data for the new child node.
Returns
- NTree<T>
The newly created child node.
GetChild(int)
Gets the child node at the specified index.
public NTree<T>? GetChild(int index)
Parameters
indexintThe zero-based index of the child to retrieve.
Returns
- NTree<T>
The child node at the specified index, or null if not found.
Traverse(NTree<T>, Action<T>)
Traverses the tree starting from the specified node, applying the visitor action to each node.
public void Traverse(NTree<T> node, Action<T> visitor)