MoreEnumerableGroupAdjacentTSource, TKey, TResult(IEnumerableTSource, FuncTSource, TKey, FuncTKey, IEnumerableTSource, TResult, IEqualityComparerTKey) Method
Groups the adjacent elements of a sequence according to a
specified key selector function. The keys are compared by using
a comparer and each group's elements are projected by using a
specified function.
Namespace: MoreLinqAssembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
public static IEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
this IEnumerable<TSource> source,
Func<TSource, TKey> keySelector,
Func<TKey, IEnumerable<TSource>, TResult> resultSelector,
IEqualityComparer<TKey>? comparer
)
<ExtensionAttribute>
Public Shared Function GroupAdjacent(Of TSource, TKey, TResult) (
source As IEnumerable(Of TSource),
keySelector As Func(Of TSource, TKey),
resultSelector As Func(Of TKey, IEnumerable(Of TSource), TResult),
comparer As IEqualityComparer(Of TKey)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename TSource, typename TKey, typename TResult>
static IEnumerable<TResult>^ GroupAdjacent(
IEnumerable<TSource>^ source,
Func<TSource, TKey>^ keySelector,
Func<TKey, IEnumerable<TSource>^, TResult>^ resultSelector,
IEqualityComparer<TKey>^ comparer
)
[<ExtensionAttribute>]
static member GroupAdjacent :
source : IEnumerable<'TSource> *
keySelector : Func<'TSource, 'TKey> *
resultSelector : Func<'TKey, IEnumerable<'TSource>, 'TResult> *
comparer : IEqualityComparer<'TKey> -> IEnumerable<'TResult>
- source IEnumerableTSource
- A sequence whose elements to group.
- keySelector FuncTSource, TKey
- A function to extract the key for each
element.
- resultSelector FuncTKey, IEnumerableTSource, TResult
- A function to map each key and
associated source elements to a result object.
- comparer IEqualityComparerTKey
- An IEqualityComparerT to
compare keys.
- TSource
- The type of the elements of
source.
- TKey
- The type of the key returned by
keySelector.
- TResult
- The type of the elements in the
resulting sequence.
IEnumerableTResultA collection of elements of type
TResult where each element represents
a projection over a group and its key.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).
This method is implemented by using deferred execution and
streams the groupings. The grouping elements, however, are
buffered. Each grouping is therefore yielded as soon as it
is complete and before the next grouping occurs.