MoreEnumerableScanByTSource, TKey, TState(IEnumerableTSource, FuncTSource, TKey, FuncTKey, TState, FuncTState, TKey, TSource, TState, IEqualityComparerTKey) Method

Applies an accumulator function over sequence element keys, returning the keys along with intermediate accumulator states. An additional parameter specifies the comparer to use to compare keys.

Definition

Namespace: MoreLinq
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
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,
	IEqualityComparer<TKey>? comparer
)

Parameters

source  IEnumerableTSource
The source sequence.
keySelector  FuncTSource, TKey
A function that returns the key given an element.
seedSelector  FuncTKey, TState
A function to determine the initial value for the accumulator that is invoked once per key encountered.
accumulator  FuncTState, TKey, TSource, TState
An accumulator function invoked for each element.
comparer  IEqualityComparerTKey
The equality comparer to use to determine whether or not keys are equal. If null, the default equality comparer for TSource is used.

Type Parameters

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

Return Value

IEnumerableKeyValuePairTKey, 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 IEnumerableTSource. 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