Method GroupAdjacent
View SourceGroupAdjacent<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>)
Groups the adjacent elements of a sequence according to a specified key selector function.
Declaration
public static IAsyncEnumerable<IGrouping<TKey, TSource>> GroupAdjacent<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | A sequence whose elements to group. |
Func<TSource, TKey> | keySelector | A function to extract the key for each element. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IGrouping<TKey, TSource>> | A sequence of groupings where each grouping (IGrouping<TKey, TElement>) contains the key and the adjacent elements in the same order as found in the source sequence. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of
|
TKey | The type of the key returned by
|
Remarks
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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
GroupAdjacent<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)
Groups the adjacent elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.
Declaration
public static IAsyncEnumerable<IGrouping<TKey, TSource>> GroupAdjacent<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | A sequence whose elements to group. |
Func<TSource, TKey> | keySelector | A function to extract the key for each element. |
IEqualityComparer<TKey> | comparer | An IEqualityComparer<T> to compare keys. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IGrouping<TKey, TSource>> | A sequence of groupings where each grouping (IGrouping<TKey, TElement>) contains the key and the adjacent elements in the same order as found in the source sequence. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of
|
TKey | The type of the key returned by
|
Remarks
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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
GroupAdjacent<TSource, TKey, TElement>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>)
Groups the adjacent elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
Declaration
public static IAsyncEnumerable<IGrouping<TKey, TElement>> GroupAdjacent<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | A sequence whose elements to group. |
Func<TSource, TKey> | keySelector | A function to extract the key for each element. |
Func<TSource, TElement> | elementSelector | A function to map each source element to an element in the resulting grouping. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IGrouping<TKey, TElement>> | A sequence of groupings where each grouping
(IGrouping<TKey, TElement>) contains the key
and the adjacent elements (of type |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of
|
TKey | The type of the key returned by
|
TElement | The type of the elements in the resulting groupings. |
Remarks
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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentNullException |
|
GroupAdjacent<TSource, TKey, TElement>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, IEqualityComparer<TKey>?)
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.
Declaration
public static IAsyncEnumerable<IGrouping<TKey, TElement>> GroupAdjacent<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey>? comparer)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | A sequence whose elements to group. |
Func<TSource, TKey> | keySelector | A function to extract the key for each element. |
Func<TSource, TElement> | elementSelector | A function to map each source element to an element in the resulting grouping. |
IEqualityComparer<TKey> | comparer | An IEqualityComparer<T> to compare keys. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IGrouping<TKey, TElement>> | A sequence of groupings where each grouping
(IGrouping<TKey, TElement>) contains the key
and the adjacent elements (of type |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of
|
TKey | The type of the key returned by
|
TElement | The type of the elements in the resulting groupings. |
Remarks
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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentNullException |
|
GroupAdjacent<TSource, TKey, TResult>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, Func<TKey, IReadOnlyList<TSource>, TResult>)
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.
Declaration
public static IAsyncEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IReadOnlyList<TSource>, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | A sequence whose elements to group. |
Func<TSource, TKey> | keySelector | A function to extract the key for each element. |
Func<TKey, IReadOnlyList<TSource>, TResult> | resultSelector | A function to map each key and associated source elements to a result object. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A collection of elements of type
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of
|
TKey | The type of the key returned by
|
TResult | The type of the elements in the resulting sequence. |
Remarks
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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentNullException |
|
GroupAdjacent<TSource, TKey, TResult>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, Func<TKey, IReadOnlyList<TSource>, TResult>, IEqualityComparer<TKey>?)
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.
Declaration
public static IAsyncEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IReadOnlyList<TSource>, TResult> resultSelector, IEqualityComparer<TKey>? comparer)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | A sequence whose elements to group. |
Func<TSource, TKey> | keySelector | A function to extract the key for each element. |
Func<TKey, IReadOnlyList<TSource>, TResult> | resultSelector | A function to map each key and associated source elements to a result object. |
IEqualityComparer<TKey> | comparer | An IEqualityComparer<T> to compare keys. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A collection of elements of type
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of
|
TKey | The type of the key returned by
|
TResult | The type of the elements in the resulting sequence. |
Remarks
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.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentNullException |
|