SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method CountBy

    CountBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>)

    Applies a key-generating function to each element of a sequence and returns a sequence of unique keys and their number of occurrences in the original sequence.

    Declaration
    public static IAsyncEnumerable<KeyValuePair<TKey, int>> CountBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    Source sequence.

    Func<TSource, TKey> keySelector

    Function that transforms each item of source sequence into a key to be compared against the others.

    Returns
    Type Description
    IAsyncEnumerable<KeyValuePair<TKey, int>>

    A sequence of unique keys and their number of occurrences in the original sequence.

    Type Parameters
    Name Description
    TSource

    Type of the elements of the source sequence.

    TKey

    Type of the projected element.

    CountBy<TSource, TKey>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)

    Applies a key-generating function to each element of a sequence and returns a sequence of unique keys and their number of occurrences in the original sequence. An additional argument specifies a comparer to use for testing equivalence of keys.

    Declaration
    public static IAsyncEnumerable<KeyValuePair<TKey, int>> CountBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    Source sequence.

    Func<TSource, TKey> keySelector

    Function that transforms each item of source sequence into a key to be compared against the others.

    IEqualityComparer<TKey> comparer

    The equality comparer to use to determine whether or not keys are equal. If null, the default equality comparer for TSource is used.

    Returns
    Type Description
    IAsyncEnumerable<KeyValuePair<TKey, int>>

    A sequence of unique keys and their number of occurrences in the original sequence.

    Type Parameters
    Name Description
    TSource

    Type of the elements of the source sequence.

    TKey

    Type of the projected element.

    © SuperLinq Authors. All rights reserved.