SuperLinq SuperLinq
SuperLinq SuperLinq
DocFX + Singulink = ♥

Search Results for

    Method Pad

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

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

    Declaration
    public static IAsyncEnumerable<TSource?> Pad<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.Pad(5);

    The result variable, when iterated over, will yield 123, 456, 789 and two zeroes, in turn.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentOutOfRangeException

    width is less than 0.

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

    Pads a sequence with a given filler value if it is narrower (shorter in length) than a given width.

    Declaration
    public static IAsyncEnumerable<TSource> Pad<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.Pad(5, -1);

    The result variable, when iterated over, will yield 123, 456, and 789 followed by two occurrences of -1, in turn.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentOutOfRangeException

    width is less than 0.

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

    Pads a sequence with a dynamic filler value if it is narrower (shorter in length) than a given width.

    Declaration
    public static IAsyncEnumerable<TSource> Pad<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.

    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 = { 0, 1, 2 };
    var result = numbers.Pad(5, i => -i);

    The result variable, when iterated over, will yield 0, 1, 2, -3 and -4, in turn.

    Exceptions
    Type Condition
    ArgumentNullException

    source is null.

    ArgumentNullException

    paddingSelector is null.

    ArgumentOutOfRangeException

    width is less than 0.

    © SuperLinq Authors. All rights reserved.