SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method WindowRight

    WindowRight<TSource>(IAsyncEnumerable<TSource>, int)

    Creates a right-aligned sliding window over the source sequence of a given size.

    Declaration
    public static IAsyncEnumerable<IList<TSource>> WindowRight<TSource>(this IAsyncEnumerable<TSource> source, int size)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    The sequence over which to create the sliding window.

    int size

    Size of the sliding window.

    Returns
    Type Description
    IAsyncEnumerable<IList<TSource>>

    A sequence representing each sliding window.

    Type Parameters
    Name Description
    TSource

    The type of the elements of source.

    Remarks

    A window can contain fewer elements than size, especially as it slides over the start of the sequence.

    This operator uses deferred execution and streams its results.

    Examples
    Console.WriteLine(
        Enumerable
            .Range(1, 5)
            .WindowRight(3)
            .Select(w => "AVG(" + w.ToDelimitedString(",") + ") = " + w.Average())
            .ToDelimitedString(Environment.NewLine));
    
    // Output:
    // AVG(1) = 1
    // AVG(1,2) = 1.5
    // AVG(1,2,3) = 2
    // AVG(2,3,4) = 3
    // AVG(3,4,5) = 4
    © SuperLinq Authors. All rights reserved.