QuickOPC User's Guide and Reference
PreventRecursion<T>(ITreeTraversable<T>,IEqualityComparer<T>) Method



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.Graphs.Extensions Namespace > ITreeTraversableExtension Class > PreventRecursion Method : PreventRecursion<T>(ITreeTraversable<T>,IEqualityComparer<T>) Method
The type of objects to traverse.
The tree traversable for which the recursion will be prevented.
The equality comparer to be used for comparing traversed nodes.
Creates a derived traversable that prevents recursion into nodes that have already been traversed, using the specified equality comparer for comparing traversed nodes.
Syntax
'Declaration
 
<ExtensionAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function PreventRecursion(Of T)( _
   ByVal source As ITreeTraversable(Of T), _
   ByVal equalityComparer As IEqualityComparer(Of T) _
) As ITreeTraversable(Of T)
'Usage
 
Dim source As ITreeTraversable(Of T)
Dim equalityComparer As IEqualityComparer(Of T)
Dim value As ITreeTraversable(Of T)
 
value = ITreeTraversableExtension.PreventRecursion(Of T)(source, equalityComparer)
[Extension()]
[NotNull()]
public static ITreeTraversable<T> PreventRecursion<T>( 
   ITreeTraversable<T> source,
   IEqualityComparer<T> equalityComparer
)
[Extension()]
[NotNull()]
public:
static ITreeTraversable<T^>^ PreventRecursiongeneric<typename T>
( 
   ITreeTraversable<T^>^ source,
   IEqualityComparer<T^>^ equalityComparer
) 

Parameters

source
The tree traversable for which the recursion will be prevented.
equalityComparer
The equality comparer to be used for comparing traversed nodes.

Type Parameters

T
The type of objects to traverse.

Return Value

Returns a tree traversable where nodes that have already been traversed are returned without their children being traversed again.
Remarks

If a node is to be returned that has already been traversed, it is still returned; only its children are not traversed again. The result thus allows reconstruction of the original tree, if so required.

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also