แก้ไข

แชร์ผ่าน


ParallelEnumerable.Aggregate Method

Definition

Applies in parallel an accumulator function over a sequence.

Overloads

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>)

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

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

Type Parameters

TSource

The type of the elements of source.

TAccumulate

The type of the accumulator value.

TResult

The type of the resulting value.

Parameters

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.

Returns

TResult

The transformed final accumulator value.

Exceptions

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 contains no elements.

See also

Applies to

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

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

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

Type Parameters

TSource

The type of the elements of source.

TAccumulate

The type of the accumulator value.

TResult

The type of the resulting value.

Parameters

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.

Returns

TResult

The transformed final accumulator value.

Exceptions

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 contains no elements.

Remarks

This overload is specific to parallelized queries. A parallelized query may partition the data source sequence into several sub-sequences (partitions). The updateAccumulatorFunc is invoked on each element within partitions. Each partition then yields a single accumulated result. The combineAccumulatorsFunc is then invoked on the results of each partition to yield a single element. This element is then transformed by the resultSelector function.

See also

Applies to

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

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

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

Type Parameters

TSource

The type of the elements of source.

TAccumulate

The type of the accumulator value.

TResult

The type of the resulting value.

Parameters

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.

Returns

TResult

The transformed final accumulator value.

Exceptions

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 contains no elements.

Remarks

This overload is specific to processing a parallelized query. A parallelized query may partition the data source sequence into several sub-sequences (partitions). The updateAccumulatorFunc is invoked on each element within partitions. Each partition then yields a single accumulated result. The combineAccumulatorsFunc is then invoked on the results of each partition to yield a single element. This element is then transformed by the resultSelector function.

See also

Applies to

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

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

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

Type Parameters

TSource

The type of the elements of source.

TAccumulate

The type of the accumulator value.

Parameters

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.

Returns

TAccumulate

The final accumulator value.

Exceptions

source or func is a null reference (Nothing in Visual Basic).

One or more exceptions occurred during the evaluation of the query.

source contains no elements.

See also

Applies to

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

Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs
Source:
ParallelEnumerable.cs

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

Type Parameters

TSource

The type of the elements of source.

Parameters

source
ParallelQuery<TSource>

A sequence to aggregate over.

func
Func<TSource,TSource,TSource>

An accumulator function to be invoked on each element.

Returns

TSource

The final accumulator value.

Exceptions

source or func is a null reference (Nothing in Visual Basic).

One or more exceptions occurred during the evaluation of the query.

source contains no elements.

See also

Applies to