ParallelEnumerable.Aggregate 方法

定义

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence.

重载

Aggregate<TSource,TAccumulate,TResult>(ParallelQuery<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TResult>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 将指定的种子值用作累加器的初始值,并使用指定的函数选择结果值。The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.

Aggregate<TSource,TAccumulate,TResult>(ParallelQuery<TSource>, Func<TAccumulate>, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TAccumulate,TAccumulate>, Func<TAccumulate,TResult>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 此重载在顺序实现中不可用。This overload is not available in the sequential implementation.

Aggregate<TSource,TAccumulate,TResult>(ParallelQuery<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TAccumulate,TAccumulate>, Func<TAccumulate,TResult>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 此重载在顺序实现中不可用。This overload is not available in the sequential implementation.

Aggregate<TSource,TAccumulate>(ParallelQuery<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 将指定的种子值用作累加器初始值。The specified seed value is used as the initial accumulator value.

Aggregate<TSource>(ParallelQuery<TSource>, Func<TSource,TSource,TSource>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence.

Aggregate<TSource,TAccumulate,TResult>(ParallelQuery<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TResult>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 将指定的种子值用作累加器的初始值,并使用指定的函数选择结果值。The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.

public:
generic <typename TSource, typename TAccumulate, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static TResult Aggregate(System::Linq::ParallelQuery<TSource> ^ source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> ^ func, Func<TAccumulate, TResult> ^ resultSelector);
public static TResult Aggregate<TSource,TAccumulate,TResult> (this System.Linq.ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> func, Func<TAccumulate,TResult> resultSelector);
static member Aggregate : System.Linq.ParallelQuery<'Source> * 'Accumulate * Func<'Accumulate, 'Source, 'Accumulate> * Func<'Accumulate, 'Result> -> 'Result
<Extension()>
Public Function Aggregate(Of TSource, TAccumulate, TResult) (source As ParallelQuery(Of TSource), seed As TAccumulate, func As Func(Of TAccumulate, TSource, TAccumulate), resultSelector As Func(Of TAccumulate, TResult)) As TResult

类型参数

TSource

source 的元素类型。The type of the elements of source.

TAccumulate

累加器值的类型。The type of the accumulator value.

TResult

结果值的类型。The type of the resulting value.

参数

source
ParallelQuery<TSource>

要对其进行聚合的序列。A sequence to aggregate over.

seed
TAccumulate

累加器的初始值。The initial accumulator value.

func
Func<TAccumulate,TSource,TAccumulate>

要对每个元素调用的累加器函数。An accumulator function to be invoked on each element.

resultSelector
Func<TAccumulate,TResult>

将累加器的最终值转换为结果值的函数。A function to transform the final accumulator value into the result value.

返回

TResult

已转换的累加器最终值。The transformed final accumulator value.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcefuncresultSelector 是 null 引用(在 Visual Basic 中为 Nothing)。source or func or resultSelector is a null reference (Nothing in Visual Basic).

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

source 中不包含任何元素。source contains no elements.

另请参阅

Aggregate<TSource,TAccumulate,TResult>(ParallelQuery<TSource>, Func<TAccumulate>, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TAccumulate,TAccumulate>, Func<TAccumulate,TResult>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 此重载在顺序实现中不可用。This overload is not available in the sequential implementation.

public:
generic <typename TSource, typename TAccumulate, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static TResult Aggregate(System::Linq::ParallelQuery<TSource> ^ source, Func<TAccumulate> ^ seedFactory, Func<TAccumulate, TSource, TAccumulate> ^ updateAccumulatorFunc, Func<TAccumulate, TAccumulate, TAccumulate> ^ combineAccumulatorsFunc, Func<TAccumulate, TResult> ^ resultSelector);
public static TResult Aggregate<TSource,TAccumulate,TResult> (this System.Linq.ParallelQuery<TSource> source, Func<TAccumulate> seedFactory, Func<TAccumulate,TSource,TAccumulate> updateAccumulatorFunc, Func<TAccumulate,TAccumulate,TAccumulate> combineAccumulatorsFunc, Func<TAccumulate,TResult> resultSelector);
static member Aggregate : System.Linq.ParallelQuery<'Source> * Func<'Accumulate> * Func<'Accumulate, 'Source, 'Accumulate> * Func<'Accumulate, 'Accumulate, 'Accumulate> * Func<'Accumulate, 'Result> -> 'Result
<Extension()>
Public Function Aggregate(Of TSource, TAccumulate, TResult) (source As ParallelQuery(Of TSource), seedFactory As Func(Of TAccumulate), updateAccumulatorFunc As Func(Of TAccumulate, TSource, TAccumulate), combineAccumulatorsFunc As Func(Of TAccumulate, TAccumulate, TAccumulate), resultSelector As Func(Of TAccumulate, TResult)) As TResult

类型参数

TSource

source 的元素类型。The type of the elements of source.

TAccumulate

累加器值的类型。The type of the accumulator value.

TResult

结果值的类型。The type of the resulting value.

参数

source
ParallelQuery<TSource>

要对其进行聚合的序列。A sequence to aggregate over.

seedFactory
Func<TAccumulate>

一个返回初始累加器值的函数。A function that returns the initial accumulator value.

updateAccumulatorFunc
Func<TAccumulate,TSource,TAccumulate>

要对分区中的每个元素调用的累加器函数。An accumulator function to be invoked on each element in a partition.

combineAccumulatorsFunc
Func<TAccumulate,TAccumulate,TAccumulate>

要对每个分区中已生成的累加器结果调用的累加器函数。An accumulator function to be invoked on the yielded accumulator result from each partition.

resultSelector
Func<TAccumulate,TResult>

将累加器的最终值转换为结果值的函数。A function to transform the final accumulator value into the result value.

返回

TResult

已转换的累加器最终值。The transformed final accumulator value.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourceseedFactoryupdateAccumulatorFunccombineAccumulatorsFuncresultSelector 是 null 引用(在 Visual Basic 中为 Nothing)。source or seedFactory or updateAccumulatorFunc or combineAccumulatorsFunc or resultSelector is a null reference (Nothing in Visual Basic).

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

source 中不包含任何元素。source contains no elements.

注解

此重载特定于并行化查询。This overload is specific to parallelized queries. 并行化查询可能将数据源序列划分为多个子序列(分区)。A parallelized query may partition the data source sequence into several sub-sequences (partitions). 对分区中的每个元素调用 updateAccumulatorFuncThe updateAccumulatorFunc is invoked on each element within partitions. 然后,每个分区生成单个累计结果。Each partition then yields a single accumulated result. 然后,对每个分区的结果调用 combineAccumulatorsFunc,以生成单个元素。The combineAccumulatorsFunc is then invoked on the results of each partition to yield a single element. 然后,resultSelector 函数对此元素进行转换。This element is then transformed by the resultSelector function.

另请参阅

Aggregate<TSource,TAccumulate,TResult>(ParallelQuery<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TAccumulate,TAccumulate>, Func<TAccumulate,TResult>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 此重载在顺序实现中不可用。This overload is not available in the sequential implementation.

public:
generic <typename TSource, typename TAccumulate, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static TResult Aggregate(System::Linq::ParallelQuery<TSource> ^ source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> ^ updateAccumulatorFunc, Func<TAccumulate, TAccumulate, TAccumulate> ^ combineAccumulatorsFunc, Func<TAccumulate, TResult> ^ resultSelector);
public static TResult Aggregate<TSource,TAccumulate,TResult> (this System.Linq.ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> updateAccumulatorFunc, Func<TAccumulate,TAccumulate,TAccumulate> combineAccumulatorsFunc, Func<TAccumulate,TResult> resultSelector);
static member Aggregate : System.Linq.ParallelQuery<'Source> * 'Accumulate * Func<'Accumulate, 'Source, 'Accumulate> * Func<'Accumulate, 'Accumulate, 'Accumulate> * Func<'Accumulate, 'Result> -> 'Result
<Extension()>
Public Function Aggregate(Of TSource, TAccumulate, TResult) (source As ParallelQuery(Of TSource), seed As TAccumulate, updateAccumulatorFunc As Func(Of TAccumulate, TSource, TAccumulate), combineAccumulatorsFunc As Func(Of TAccumulate, TAccumulate, TAccumulate), resultSelector As Func(Of TAccumulate, TResult)) As TResult

类型参数

TSource

source 的元素类型。The type of the elements of source.

TAccumulate

累加器值的类型。The type of the accumulator value.

TResult

结果值的类型。The type of the resulting value.

参数

source
ParallelQuery<TSource>

要对其进行聚合的序列。A sequence to aggregate over.

seed
TAccumulate

累加器的初始值。The initial accumulator value.

updateAccumulatorFunc
Func<TAccumulate,TSource,TAccumulate>

要对分区中的每个元素调用的累加器函数。An accumulator function to be invoked on each element in a partition.

combineAccumulatorsFunc
Func<TAccumulate,TAccumulate,TAccumulate>

要对每个分区中已生成的累加器结果调用的累加器函数。An accumulator function to be invoked on the yielded accumulator result from each partition.

resultSelector
Func<TAccumulate,TResult>

将累加器的最终值转换为结果值的函数。A function to transform the final accumulator value into the result value.

返回

TResult

已转换的累加器最终值。The transformed final accumulator value.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourceupdateAccumulatorFunccombineAccumulatorsFuncresultSelector 是 null 引用(在 Visual Basic 中为 Nothing)。source or updateAccumulatorFunc or combineAccumulatorsFunc or resultSelector is a null reference (Nothing in Visual Basic).

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

source 中不包含任何元素。source contains no elements.

注解

此重载特定于处理并行化查询。This overload is specific to processing a parallelized query. 并行化查询可能将数据源序列划分为多个子序列(分区)。A parallelized query may partition the data source sequence into several sub-sequences (partitions). 对分区中的每个元素调用 updateAccumulatorFuncThe updateAccumulatorFunc is invoked on each element within partitions. 然后,每个分区生成单个累计结果。Each partition then yields a single accumulated result. 然后,对每个分区的结果调用 combineAccumulatorsFunc,以生成单个元素。The combineAccumulatorsFunc is then invoked on the results of each partition to yield a single element. 然后,resultSelector 函数对此元素进行转换。This element is then transformed by the resultSelector function.

另请参阅

Aggregate<TSource,TAccumulate>(ParallelQuery<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence. 将指定的种子值用作累加器初始值。The specified seed value is used as the initial accumulator value.

public:
generic <typename TSource, typename TAccumulate>
[System::Runtime::CompilerServices::Extension]
 static TAccumulate Aggregate(System::Linq::ParallelQuery<TSource> ^ source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> ^ func);
public static TAccumulate Aggregate<TSource,TAccumulate> (this System.Linq.ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> func);
static member Aggregate : System.Linq.ParallelQuery<'Source> * 'Accumulate * Func<'Accumulate, 'Source, 'Accumulate> -> 'Accumulate
<Extension()>
Public Function Aggregate(Of TSource, TAccumulate) (source As ParallelQuery(Of TSource), seed As TAccumulate, func As Func(Of TAccumulate, TSource, TAccumulate)) As TAccumulate

类型参数

TSource

source 的元素类型。The type of the elements of source.

TAccumulate

累加器值的类型。The type of the accumulator value.

参数

source
ParallelQuery<TSource>

要对其进行聚合的序列。A sequence to aggregate over.

seed
TAccumulate

累加器的初始值。The initial accumulator value.

func
Func<TAccumulate,TSource,TAccumulate>

要对每个元素调用的累加器函数。An accumulator function to be invoked on each element.

返回

TAccumulate

累加器的最终值。The final accumulator value.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcefunc 为 null 引用(在 Visual Basic 中为 Nothing)。source or func is a null reference (Nothing in Visual Basic).

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

source 中不包含任何元素。source contains no elements.

另请参阅

Aggregate<TSource>(ParallelQuery<TSource>, Func<TSource,TSource,TSource>)

对一个序列并行应用累加器函数。Applies in parallel an accumulator function over a sequence.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static TSource Aggregate(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TSource, TSource> ^ func);
public static TSource Aggregate<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TSource,TSource> func);
static member Aggregate : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Source, 'Source> -> 'Source
<Extension()>
Public Function Aggregate(Of TSource) (source As ParallelQuery(Of TSource), func As Func(Of TSource, TSource, TSource)) As TSource

类型参数

TSource

source 的元素类型。The type of the elements of source.

参数

source
ParallelQuery<TSource>

要对其进行聚合的序列。A sequence to aggregate over.

func
Func<TSource,TSource,TSource>

要对每个元素调用的累加器函数。An accumulator function to be invoked on each element.

返回

TSource

累加器的最终值。The final accumulator value.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcefunc 为 null 引用(在 Visual Basic 中为 Nothing)。source or func is a null reference (Nothing in Visual Basic).

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

source 中不包含任何元素。source contains no elements.

另请参阅

适用于