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.

C#
public static TResult Aggregate<TSource,TAccumulate,TResult>(this System.Linq.ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> func, Func<TAccumulate,TResult> resultSelector);

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

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
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);

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

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
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);

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

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
public static TAccumulate Aggregate<TSource,TAccumulate>(this System.Linq.ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> func);

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

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
public static TSource Aggregate<TSource>(this System.Linq.ParallelQuery<TSource> source, Func<TSource,TSource,TSource> func);

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

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0