Class TreeExtensions
Extensions to work with trees.
public static class TreeExtensions
- Inheritance
-
TreeExtensions
- Inherited Members
Methods
TraverseFlat<T>(T)
Convert tree to a list of nodes in Bredth First Order. Returns a tuples of nodes with their depth.
public static IEnumerable<(T node, int depth)> TraverseFlat<T>(this T node) where T : ITree<T>
Parameters
nodeT
Returns
- IEnumerable<(T value, int index)>
Type Parameters
T
TraverseFlat<T>(T, Func<T, IEnumerable<T>>, int)
Convert tree to a list of nodes in Breadth First Order using getChildren to find the nodes children. Returns a tuples of nodes with their depth.
public static IEnumerable<(T node, int depth)> TraverseFlat<T>(this T node, Func<T, IEnumerable<T>> getChildren, int depth = 0)
Parameters
nodeTgetChildrenFunc<T, IEnumerable<T>>depthint
Returns
- IEnumerable<(T value, int index)>
Type Parameters
T
Traverse<T>(T, Action<T, int>)
Visit each node, with it's depth, in the tree in a breadth first order.
public static void Traverse<T>(this T node, Action<T, int> visitor) where T : ITree<T>
Parameters
Type Parameters
T
Traverse<T>(T, Action<T, int>, Func<T, IEnumerable<T>>)
Visit each node, with it's depth, in a tree using the getChildren function to find children.
public static void Traverse<T>(this T node, Action<T, int> visitor, Func<T, IEnumerable<T>> getChildren)
Parameters
nodeTvisitorAction<T, int>getChildrenFunc<T, IEnumerable<T>>
Type Parameters
T
Traverse<T>(T, Action<T>)
Visit each node in the tree in breadth first order.
public static void Traverse<T>(this T node, Action<T> visitor) where T : ITree<T>
Parameters
nodeTvisitorAction<T>
Type Parameters
T
Traverse<T>(T, Action<T>, Func<T, IEnumerable<T>>)
Visit each node in a tree using the getChildren function to find children.
public static void Traverse<T>(this T node, Action<T> visitor, Func<T, IEnumerable<T>> getChildren)
Parameters
nodeTvisitorAction<T>getChildrenFunc<T, IEnumerable<T>>
Type Parameters
T