| TreeHelperGetSubtreeT Method (T, FuncT, IEnumerableT, Boolean) |
Gets the subtree (the given node and all of its descendants) using a depth-first search or a
breadth-first search.
Namespace: DigitalRune.LinqAssembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax public static IEnumerable<T> GetSubtree<T>(
T node,
Func<T, IEnumerable<T>> getChildren,
bool depthFirst
)
where T : class
Public Shared Function GetSubtree(Of T As Class) (
node As T,
getChildren As Func(Of T, IEnumerable(Of T)),
depthFirst As Boolean
) As IEnumerable(Of T)
public:
generic<typename T>
where T : ref class
static IEnumerable<T>^ GetSubtree(
T node,
Func<T, IEnumerable<T>^>^ getChildren,
bool depthFirst
)
static member GetSubtree :
node : 'T *
getChildren : Func<'T, IEnumerable<'T>> *
depthFirst : bool -> IEnumerable<'T> when 'T : not struct
Parameters
- node
- Type: T
The reference node where to start the search. (The reference node will be the first element
in the enumeration.)
- getChildren
- Type: SystemFuncT, IEnumerableT
A method that retrieves the children of an object of type T.
GetSubtreeT(T, FuncT, IEnumerableT) guarantees that
getChildren is never called with as parameter. The
enumeration returned by getChildren may contain .
- depthFirst
- Type: SystemBoolean
If set to then a depth-first search for descendants will be made;
otherwise a breadth-first search will be made.
Type Parameters
- T
- The type of node that is enumerated.
Return Value
Type:
IEnumerableTThe subtree of
node.
Exceptions Remarks
This method can be used to traverse a tree in either depth-first order (preorder) or in
breadth-first order (also known as level-order).
See Also