SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method IndexBy

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

    Applies a key-generating function to each element of a sequence and returns a sequence that contains the elements of the original sequence as well its key and index inside the group of its key.

    Declaration
    public static IAsyncEnumerable<(int index, TSource item)> IndexBy<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 projects the key given an element in the source sequence.

    Returns
    Type Description
    IAsyncEnumerable<(int index, TSource item)>

    A sequence of elements paired with their index within the key-group. The index is the key and the element is the value of the pair.

    Type Parameters
    Name Description
    TSource

    Type of the source sequence elements.

    TKey

    Type of the projected key.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentNullException

    keySelector is null.

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

    Applies a key-generating function to each element of a sequence and returns a sequence that contains the elements of the original sequence as well its key and index inside the group of its key. An additional parameter specifies a comparer to use for testing the equivalence of keys.

    Declaration
    public static IAsyncEnumerable<(int index, TSource item)> IndexBy<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 projects the key given an element in the source sequence.

    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<(int index, TSource item)>

    A sequence of elements paired with their index within the key-group. The index is the key and the element is the value of the pair.

    Type Parameters
    Name Description
    TSource

    Type of the source sequence elements.

    TKey

    Type of the projected key.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentNullException

    keySelector is null.

    © SuperLinq Authors. All rights reserved.