Method Lead
View SourceLead<TSource>(IAsyncEnumerable<TSource>, int)
Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
Declaration
public static IAsyncEnumerable<(TSource current, TSource? lead)> Lead<TSource>(this IAsyncEnumerable<TSource> source, int offset)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate lag |
int | offset | The offset (expressed as a positive number) by which to lag each value of the sequence |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource current, TSource lag)> | A sequence of tuples with the current and lagged elements |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the source sequence |
Remarks
This operator evaluates in a deferred and streaming manner.
For elements prior to the lag offset, default(TSource
?) is used as the lagged value.
Lead<TSource, TResult>(IAsyncEnumerable<TSource>, int, Func<TSource, TSource?, TResult>)
Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset.
Declaration
public static IAsyncEnumerable<TResult> Lead<TSource, TResult>(this IAsyncEnumerable<TSource> source, int offset, Func<TSource, TSource?, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate Lead |
int | offset | The offset (expressed as a positive number) by which to lead each element of the sequence |
Func<TSource, TSource, TResult> | resultSelector | A projection function which accepts the current and subsequent (lead) element (in that order) and produces a result |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence produced by projecting each element of the sequence with its lead pairing |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TResult | The type of the elements in the result sequence |
Remarks
This operator evaluates in a deferred and streaming manner.
For elements of the sequence that are less than offset
items from the end,
default(TSource
?) is used as the lead value.
Lead<TSource, TResult>(IAsyncEnumerable<TSource>, int, TSource, Func<TSource, TSource, TResult>)
Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset.
Declaration
public static IAsyncEnumerable<TResult> Lead<TSource, TResult>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLeadValue, Func<TSource, TSource, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate Lead |
int | offset | The offset (expressed as a positive number) by which to lead each element of the sequence |
TSource | defaultLeadValue | A default value supplied for the leading element when none is available |
Func<TSource, TSource, TResult> | resultSelector | A projection function which accepts the current and subsequent (lead) element (in that order) and produces a result |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence produced by projecting each element of the sequence with its lead pairing |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TResult | The type of the elements in the result sequence |
Remarks
This operator evaluates in a deferred and streaming manner.
Lead<TSource, TResult>(IAsyncEnumerable<TSource>, int, TSource, Func<TSource, TSource, ValueTask<TResult>>)
Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset.
Declaration
public static IAsyncEnumerable<TResult> Lead<TSource, TResult>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLeadValue, Func<TSource, TSource, ValueTask<TResult>> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate Lead |
int | offset | The offset (expressed as a positive number) by which to lead each element of the sequence |
TSource | defaultLeadValue | A default value supplied for the leading element when none is available |
Func<TSource, TSource, ValueTask<TResult>> | resultSelector | A projection function which accepts the current and subsequent (lead) element (in that order) and produces a result |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence produced by projecting each element of the sequence with its lead pairing |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence |
TResult | The type of the elements in the result sequence |
Remarks
This operator evaluates in a deferred and streaming manner.