AsyncEnumerableExtensions.ChunkByKey<TSource,TKey> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Chunks the async enumerable sequence into groups based on a key selector function.
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.IAsyncEnumerable<TSource>> ChunkByKey<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ChunkByKey : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.IAsyncEnumerable<'Source>>
<Extension()>
Public Function ChunkByKey(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of IAsyncEnumerable(Of TSource))
Type Parameters
- TSource
The type of elements in the source sequence.
- TKey
The type of the key used for grouping.
Parameters
- source
- IAsyncEnumerable<TSource>
The source async enumerable sequence.
- keySelector
- Func<TSource,TKey>
A function to extract the key from each element.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys. If null, uses the default equality comparer.
- cancellationToken
- CancellationToken
A cancellation token to observe while enumerating the sequence.
Returns
An async enumerable of async enumerable chunks, where each chunk contains consecutive elements with the same key.