ImmutableArrayExtensions.Aggregate 方法

定义

重载

Aggregate<T>(ImmutableArray<T>, Func<T,T,T>)

以累加方式向元素序列应用函数。Applies a function to a sequence of elements in a cumulative way.

Aggregate<TAccumulate,T>(ImmutableArray<T>, TAccumulate, Func<TAccumulate,T,TAccumulate>)

以累加方式向元素序列应用函数。Applies a function to a sequence of elements in a cumulative way.

Aggregate<TAccumulate,TResult,T>(ImmutableArray<T>, TAccumulate, Func<TAccumulate,T,TAccumulate>, Func<TAccumulate,TResult>)

以累加方式向元素序列应用函数。Applies a function to a sequence of elements in a cumulative way.

Aggregate<T>(ImmutableArray<T>, Func<T,T,T>)

以累加方式向元素序列应用函数。Applies a function to a sequence of elements in a cumulative way.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Aggregate(System::Collections::Immutable::ImmutableArray<T> immutableArray, Func<T, T, T> ^ func);
public static T Aggregate<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,T,T> func);
static member Aggregate : System.Collections.Immutable.ImmutableArray<'T> * Func<'T, 'T, 'T> -> 'T
<Extension()>
Public Function Aggregate(Of T) (immutableArray As ImmutableArray(Of T), func As Func(Of T, T, T)) As T

类型参数

T

集合包含的元素的类型。The type of element contained by the collection.

参数

immutableArray
ImmutableArray<T>

要将函数应用到的集合。The collection to apply the function to.

func
Func<T,T,T>

要以累加方式对每个元素调用的函数。A function to be invoked on each element, in a cumulative way.

返回

T

向所有元素应用累加函数后得到的最终值。The final value after the cumulative function has been applied to all elements.

注解

Aggregate方法可简化对值序列执行计算的过程。Aggregate method makes it simple to perform a calculation over a sequence of values. 此方法的工作方式func为: 为源中的每个元素调用一次。This method works by calling func one time for each element in source. 每次func调用时, Aggregate都会同时传递序列中的元素和聚合值 (作为 func 的第一个参数)。Each time func is called, Aggregate passes both the element from the sequence and an aggregated value (as the first argument to func). seed参数的值用作初始聚合值。The value of the seed parameter is used as the initial aggregate value. 替换上一个func聚合值的结果。The result of func replaces the previous aggregated value. Aggregate返回最终结果funcAggregate returns the final result of func.

Aggregate<TAccumulate,T>(ImmutableArray<T>, TAccumulate, Func<TAccumulate,T,TAccumulate>)

以累加方式向元素序列应用函数。Applies a function to a sequence of elements in a cumulative way.

public:
generic <typename TAccumulate, typename T>
[System::Runtime::CompilerServices::Extension]
 static TAccumulate Aggregate(System::Collections::Immutable::ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate, T, TAccumulate> ^ func);
public static TAccumulate Aggregate<TAccumulate,T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate,T,TAccumulate> func);
static member Aggregate : System.Collections.Immutable.ImmutableArray<'T> * 'Accumulate * Func<'Accumulate, 'T, 'Accumulate> -> 'Accumulate
<Extension()>
Public Function Aggregate(Of TAccumulate, T) (immutableArray As ImmutableArray(Of T), seed As TAccumulate, func As Func(Of TAccumulate, T, TAccumulate)) As TAccumulate

类型参数

TAccumulate

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

T

集合包含的元素的类型。The type of element contained by the collection.

参数

immutableArray
ImmutableArray<T>

要将函数应用到的集合。The collection to apply the function to.

seed
TAccumulate

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

func
Func<TAccumulate,T,TAccumulate>

要以累加方式对每个元素调用的函数。A function to be invoked on each element, in a cumulative way.

返回

TAccumulate

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

注解

Aggregate方法可简化对值序列执行计算的过程。Aggregate method makes it simple to perform a calculation over a sequence of values. 此方法的工作方式func为: 为源中的每个元素调用一次。This method works by calling func one time for each element in source. 每次func调用时, Aggregate都会同时传递序列中的元素和聚合值 (作为 func 的第一个参数)。Each time func is called, Aggregate passes both the element from the sequence and an aggregated value (as the first argument to func). seed参数的值用作初始聚合值。The value of the seed parameter is used as the initial aggregate value. 替换上一个func聚合值的结果。The result of func replaces the previous aggregated value. Aggregate返回最终结果funcAggregate returns the final result of func.

Aggregate<TAccumulate,TResult,T>(ImmutableArray<T>, TAccumulate, Func<TAccumulate,T,TAccumulate>, Func<TAccumulate,TResult>)

以累加方式向元素序列应用函数。Applies a function to a sequence of elements in a cumulative way.

public:
generic <typename TAccumulate, typename TResult, typename T>
[System::Runtime::CompilerServices::Extension]
 static TResult Aggregate(System::Collections::Immutable::ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate, T, TAccumulate> ^ func, Func<TAccumulate, TResult> ^ resultSelector);
public static TResult Aggregate<TAccumulate,TResult,T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate,T,TAccumulate> func, Func<TAccumulate,TResult> resultSelector);
static member Aggregate : System.Collections.Immutable.ImmutableArray<'T> * 'Accumulate * Func<'Accumulate, 'T, 'Accumulate> * Func<'Accumulate, 'Result> -> 'Result
<Extension()>
Public Function Aggregate(Of TAccumulate, TResult, T) (immutableArray As ImmutableArray(Of T), seed As TAccumulate, func As Func(Of TAccumulate, T, TAccumulate), resultSelector As Func(Of TAccumulate, TResult)) As TResult

类型参数

TAccumulate

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

TResult

结果选择器返回的结果类型。The type of result returned by the result selector.

T

集合包含的元素的类型。The type of element contained by the collection.

参数

immutableArray
ImmutableArray<T>

要将函数应用到的集合。The collection to apply the function to.

seed
TAccumulate

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

func
Func<TAccumulate,T,TAccumulate>

要以累加方式对每个元素调用的函数。A function to be invoked on each element, in a cumulative way.

resultSelector
Func<TAccumulate,TResult>

返回

TResult

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

注解

Aggregate方法可简化对值序列执行计算的过程。Aggregate method makes it simple to perform a calculation over a sequence of values. 此方法的工作方式func为: 为源中的每个元素调用一次。This method works by calling func one time for each element in source. 每次func调用时, Aggregate都会同时传递序列中的元素和聚合值 (作为 func 的第一个参数)。Each time func is called, Aggregate passes both the element from the sequence and an aggregated value (as the first argument to func). seed参数的值用作初始聚合值。The value of the seed parameter is used as the initial aggregate value. 替换上一个func聚合值的结果。The result of func replaces the previous aggregated value. Aggregate返回最终结果funcAggregate returns the final result of func.

适用于