SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method PadStart

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

    Pads a sequence with default values in the beginning if it is narrower (shorter in length) than a given width.

    Declaration
    public static IAsyncEnumerable<TSource?> PadStart<TSource>(this IAsyncEnumerable<TSource> source, int width)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    The sequence to pad.

    int width

    The width/length below which to pad.

    Returns
    Type Description
    IAsyncEnumerable<TSource>

    Returns a sequence that is at least as wide/long as the width/length specified by the width parameter.

    Type Parameters
    Name Description
    TSource

    The type of the elements of source.

    Remarks

    This operator uses deferred execution and streams its results.

    Examples
    int[] numbers = { 123, 456, 789 };
    var result = numbers.PadStart(5);

    The result variable will contain { 0, 0, 123, 456, 789 }.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentOutOfRangeException

    width is less than 0.

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

    Pads a sequence with a given filler value in the beginning if it is narrower (shorter in length) than a given width. An additional parameter specifies the value to use for padding.

    Declaration
    public static IAsyncEnumerable<TSource> PadStart<TSource>(this IAsyncEnumerable<TSource> source, int width, TSource padding)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    The sequence to pad.

    int width

    The width/length below which to pad.

    TSource padding

    The value to use for padding.

    Returns
    Type Description
    IAsyncEnumerable<TSource>

    Returns a sequence that is at least as wide/long as the width/length specified by the width parameter.

    Type Parameters
    Name Description
    TSource

    The type of the elements of source.

    Remarks

    This operator uses deferred execution and streams its results.

    Examples
    int[] numbers = { 123, 456, 789 };
    var result = numbers.PadStart(5, -1);

    The result variable will contain { -1, -1, 123, 456, 789 }.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentOutOfRangeException

    width is less than 0.

    PadStart<TSource>(IAsyncEnumerable<TSource>, int, Func<int, TSource>)

    Pads a sequence with a dynamic filler value in the beginning if it is narrower (shorter in length) than a given width. An additional parameter specifies the function to calculate padding.

    Declaration
    public static IAsyncEnumerable<TSource> PadStart<TSource>(this IAsyncEnumerable<TSource> source, int width, Func<int, TSource> paddingSelector)
    Parameters
    Type Name Description
    IAsyncEnumerable<TSource> source

    The sequence to pad.

    int width

    The width/length below which to pad.

    Func<int, TSource> paddingSelector

    Function to calculate padding given the index of the missing element.

    Returns
    Type Description
    IAsyncEnumerable<TSource>

    Returns a sequence that is at least as wide/long as the width/length specified by the width parameter.

    Type Parameters
    Name Description
    TSource

    The type of the elements of source.

    Remarks

    This operator uses deferred execution and streams its results.

    Examples
    int[] numbers = { 123, 456, 789 };
    var result = numbers.PadStart(6, i => -i);

    The result variable will contain { 0, -1, -2, 123, 456, 789 }.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentNullException

    paddingSelector is null.

    ArgumentOutOfRangeException

    width is less than 0.

    © SuperLinq Authors. All rights reserved.