OPC Studio 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 value of this parameter cannot be null (Nothing in Visual Basic).

The equality comparer to be used for comparing traversed nodes.

The value of this parameter cannot be null (Nothing in Visual Basic).

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.

The value of this parameter cannot be null (Nothing in Visual Basic).

equalityComparer
The equality comparer to be used for comparing traversed nodes.

The value of this parameter cannot be null (Nothing in Visual Basic).

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.

This method never returns null (Nothing in Visual Basic).

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.

This is an extension method (info: C#, VB.NET). In languages that have support for extensions methods (such as C# and VB.NET), you can use the extension method as if it were a regular method on the object that is its first parameter. In other languages (such as with Python.NET), you will call the extension as a static method, and pass it the object on which it acts as its first parameter.

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