AsyncEnumerable.AggregateBy 方法

定义

重载

名称 说明
AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,TAccumulate>, Func<TAccumulate, TSource,TAccumulate>, IEqualityComparer<TKey>)

对序列应用累加器函数,按键对结果进行分组。

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

对序列应用累加器函数,按键对结果进行分组。

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

对序列应用累加器函数,按键对结果进行分组。

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

对序列应用累加器函数,按键对结果进行分组。

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,TAccumulate>, Func<TAccumulate, TSource,TAccumulate>, IEqualityComparer<TKey>)

Source:
AggregateBy.cs
Source:
AggregateBy.cs
Source:
AggregateBy.cs

对序列应用累加器函数,按键对结果进行分组。

public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TKey,TAccumulate> seedSelector, Func<TAccumulate,TSource,TAccumulate> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);
static member AggregateBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * Func<'Key, 'Accumulate> * Func<'Accumulate, 'Source, 'Accumulate> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, 'Accumulate>>
<Extension()>
Public Function AggregateBy(Of TSource, TKey, TAccumulate) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), seedSelector As Func(Of TKey, TAccumulate), func As Func(Of TAccumulate, TSource, TAccumulate), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of KeyValuePair(Of TKey, TAccumulate))

类型参数

TSource

的元素 source的类型。

TKey

返回 keySelector的键的类型。

TAccumulate

累加器值的类型。

参数

source
IAsyncEnumerable<TSource>

要聚合的集合 IAsyncEnumerable<T>

keySelector
Func<TSource,TKey>

用于提取每个元素的键的函数。

seedSelector
Func<TKey,TAccumulate>

初始累加器值的工厂。

func
Func<TAccumulate,TSource,TAccumulate>

要在每个元素上调用的累加器函数。

keyComparer
IEqualityComparer<TKey>

与键进行比较的一个 IEqualityComparer<T>

返回

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

一个枚举,包含与派生自 source的每个键对应的聚合。

例外

funcnull

注解

此方法与 GroupBy 方法相当,其中每个分组都聚合为单个值,而不是为每个组分配集合。

适用于

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

Source:
AggregateBy.cs
Source:
AggregateBy.cs
Source:
AggregateBy.cs

对序列应用累加器函数,按键对结果进行分组。

public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);
static member AggregateBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * 'Accumulate * Func<'Accumulate, 'Source, 'Accumulate> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, 'Accumulate>>
<Extension()>
Public Function AggregateBy(Of TSource, TKey, TAccumulate) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), seed As TAccumulate, func As Func(Of TAccumulate, TSource, TAccumulate), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of KeyValuePair(Of TKey, TAccumulate))

类型参数

TSource

的元素 source的类型。

TKey

返回 keySelector的键的类型。

TAccumulate

累加器值的类型。

参数

source
IAsyncEnumerable<TSource>

要聚合的集合 IAsyncEnumerable<T>

keySelector
Func<TSource,TKey>

用于提取每个元素的键的函数。

seed
TAccumulate

初始累加器值。

func
Func<TAccumulate,TSource,TAccumulate>

要在每个元素上调用的累加器函数。

keyComparer
IEqualityComparer<TKey>

与键进行比较的一个 IEqualityComparer<T>

返回

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

一个枚举,包含与派生自 source的每个键对应的聚合。

例外

funcnull

注解

此方法与 GroupBy 方法相当,其中每个分组都聚合为单个值,而不是为每个组分配集合。

适用于

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

Source:
AggregateBy.cs
Source:
AggregateBy.cs
Source:
AggregateBy.cs

对序列应用累加器函数,按键对结果进行分组。

public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, Func<TKey,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TAccumulate>> seedSelector, Func<TAccumulate,TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TAccumulate>> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);
static member AggregateBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * Func<'Key, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Accumulate>> * Func<'Accumulate, 'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Accumulate>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, 'Accumulate>>
<Extension()>
Public Function AggregateBy(Of TSource, TKey, TAccumulate) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), seedSelector As Func(Of TKey, CancellationToken, ValueTask(Of TAccumulate)), func As Func(Of TAccumulate, TSource, CancellationToken, ValueTask(Of TAccumulate)), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of KeyValuePair(Of TKey, TAccumulate))

类型参数

TSource

的元素 source的类型。

TKey

返回 keySelector的键的类型。

TAccumulate

累加器值的类型。

参数

source
IAsyncEnumerable<TSource>

要聚合的集合 IAsyncEnumerable<T>

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

用于提取每个元素的键的函数。

seedSelector
Func<TKey,CancellationToken,ValueTask<TAccumulate>>

初始累加器值的工厂。

func
Func<TAccumulate,TSource,CancellationToken,ValueTask<TAccumulate>>

要在每个元素上调用的累加器函数。

keyComparer
IEqualityComparer<TKey>

与键进行比较的一个 IEqualityComparer<T>

返回

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

一个枚举,包含与派生自 source的每个键对应的聚合。

例外

funcnull

注解

此方法与 GroupBy 方法相当,其中每个分组都聚合为单个值,而不是为每个组分配集合。

适用于

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

Source:
AggregateBy.cs
Source:
AggregateBy.cs
Source:
AggregateBy.cs

对序列应用累加器函数,按键对结果进行分组。

public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, TAccumulate seed, Func<TAccumulate,TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TAccumulate>> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);
static member AggregateBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * 'Accumulate * Func<'Accumulate, 'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Accumulate>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, 'Accumulate>>
<Extension()>
Public Function AggregateBy(Of TSource, TKey, TAccumulate) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), seed As TAccumulate, func As Func(Of TAccumulate, TSource, CancellationToken, ValueTask(Of TAccumulate)), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of KeyValuePair(Of TKey, TAccumulate))

类型参数

TSource

的元素 source的类型。

TKey

返回 keySelector的键的类型。

TAccumulate

累加器值的类型。

参数

source
IAsyncEnumerable<TSource>

要聚合的集合 IAsyncEnumerable<T>

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

用于提取每个元素的键的函数。

seed
TAccumulate

初始累加器值。

func
Func<TAccumulate,TSource,CancellationToken,ValueTask<TAccumulate>>

要在每个元素上调用的累加器函数。

keyComparer
IEqualityComparer<TKey>

与键进行比较的一个 IEqualityComparer<T>

返回

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

一个枚举,包含与派生自 source的每个键对应的聚合。

例外

funcnull

注解

此方法与 GroupBy 方法相当,其中每个分组都聚合为单个值,而不是为每个组分配集合。

适用于