Redigera

Dela via


AsyncEnumerable.IntersectBy Method

Definition

Overloads

IntersectBy<TSource,TKey>(IAsyncEnumerable<TSource>, IAsyncEnumerable<TKey>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>)

Produces the set intersection of two sequences according to a specified key selector function.

IntersectBy<TSource,TKey>(IAsyncEnumerable<TSource>, IAsyncEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Produces the set intersection of two sequences according to a specified key selector function.

IntersectBy<TSource,TKey>(IAsyncEnumerable<TSource>, IAsyncEnumerable<TKey>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>)

Source:
IntersectBy.cs

Produces the set intersection of two sequences according to a specified key selector function.

public static System.Collections.Generic.IAsyncEnumerable<TSource> IntersectBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> first, System.Collections.Generic.IAsyncEnumerable<TKey> second, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default);
static member IntersectBy : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Collections.Generic.IAsyncEnumerable<'Key> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function IntersectBy(Of TSource, TKey) (first As IAsyncEnumerable(Of TSource), second As IAsyncEnumerable(Of TKey), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional comparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of TSource)

Type Parameters

TSource

The type of the elements of the input sequences.

TKey

The type of key to identify elements by.

Parameters

first
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> whose distinct elements that also appear in second will be returned.

second
IAsyncEnumerable<TKey>

An IAsyncEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

keySelector
Func<TSource,CancellationToken,ValueTask<TKey>>

A function to extract the key for each element.

comparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys.

Returns

IAsyncEnumerable<TSource>

A sequence that contains the elements that form the set intersection of two sequences.

Exceptions

keySelector is null.

Remarks

This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.

The intersection of two sets A and B is defined as the set that contains all the elements of A that also appear in B, but no other elements.

When the object returned by this method is enumerated, `Intersect` yields distinct elements occurring in both sequences in the order in which they appear in first.

If comparer is null, the default equality comparer, Default, is used to compare values.

Applies to

IntersectBy<TSource,TKey>(IAsyncEnumerable<TSource>, IAsyncEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Source:
IntersectBy.cs

Produces the set intersection of two sequences according to a specified key selector function.

public static System.Collections.Generic.IAsyncEnumerable<TSource> IntersectBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> first, System.Collections.Generic.IAsyncEnumerable<TKey> second, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default);
static member IntersectBy : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Collections.Generic.IAsyncEnumerable<'Key> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function IntersectBy(Of TSource, TKey) (first As IAsyncEnumerable(Of TSource), second As IAsyncEnumerable(Of TKey), keySelector As Func(Of TSource, TKey), Optional comparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of TSource)

Type Parameters

TSource

The type of the elements of the input sequences.

TKey

The type of key to identify elements by.

Parameters

first
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> whose distinct elements that also appear in second will be returned.

second
IAsyncEnumerable<TKey>

An IAsyncEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

keySelector
Func<TSource,TKey>

A function to extract the key for each element.

comparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys.

Returns

IAsyncEnumerable<TSource>

A sequence that contains the elements that form the set intersection of two sequences.

Exceptions

keySelector is null.

Remarks

This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.

The intersection of two sets A and B is defined as the set that contains all the elements of A that also appear in B, but no other elements.

When the object returned by this method is enumerated, `Intersect` yields distinct elements occurring in both sequences in the order in which they appear in first.

If comparer is null, the default equality comparer, Default, is used to compare values.

Applies to