ScanByExtension.ScanBy<TSource, TKey, TState>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TKey, TState>, Func<TState, TKey, TSource, TState>) Method

Applies an accumulator function over sequence element keys, returning the keys along with intermediate accumulator states.

Definition

Namespace: MoreLinq.Extensions
Assembly: MoreLinq (in MoreLinq.dll) Version: 4.0.0+092a40d82a1b280568ffa006d9a210bdec0792cd
C#
public static IEnumerable<KeyValuePair<TKey, TState>> ScanBy<TSource, TKey, TState>(
	this IEnumerable<TSource> source,
	Func<TSource, TKey> keySelector,
	Func<TKey, TState> seedSelector,
	Func<TState, TKey, TSource, TState> accumulator
)

Parameters

source  IEnumerable<TSource>
The source sequence.
keySelector  Func<TSource, TKey>
A function that returns the key given an element.
seedSelector  Func<TKey, TState>
A function to determine the initial value for the accumulator that is invoked once per key encountered.
accumulator  Func<TState, TKey, TSource, TState>
An accumulator function invoked for each element.

Type Parameters

TSource
Type of the elements of the source sequence.
TKey
The type of the key.
TState
Type of the state.

Return Value

IEnumerable<KeyValuePair<TKey, TState>>
A sequence of keys paired with intermediate accumulator states.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<TSource>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also