Class GorgonTreeLinqExtensions
LINQ extension methods for tree structures.
Inherited Members
Namespace: Gorgon.Collections
Assembly: Gorgon.Core.dll
Syntax
public static class GorgonTreeLinqExtensions
Methods
| Edit this page View SourceTraverseDepthFirst<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
Function to flatten a tree of objects into a flat traversable list using a depth first approach.
Declaration
public static IEnumerable<T> TraverseDepthFirst<T>(this IEnumerable<T> children, Func<T, IEnumerable<T>> getChildren)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | children | The list of objects to evaluate. |
Func<T, IEnumerable<T>> | getChildren | The method to retrieve the next level of children. |
Returns
Type | Description |
---|---|
IEnumerable<T> | An enumerable containing the flattened list of objects. |
Type Parameters
Name | Description |
---|---|
T | The type of value in the tree. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Traverse<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
Function to flatten a tree of objects into a flat traversable list using a breadth first approach.
Declaration
public static IEnumerable<T> Traverse<T>(this IEnumerable<T> children, Func<T, IEnumerable<T>> getChildren)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | children | The list of objects to evaluate. |
Func<T, IEnumerable<T>> | getChildren | The method to retrieve the next level of children. |
Returns
Type | Description |
---|---|
IEnumerable<T> | An enumerable containing the flattened list of objects. |
Type Parameters
Name | Description |
---|---|
T | The type of value in the tree. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |