Method WhereLead
View SourceWhereLead<TSource>(IAsyncEnumerable<TSource>, int, Func<TSource, TSource?, bool>)
Filters a sequence of values based on a predicate evaluated on the current value and a leading value.
Declaration
public static IAsyncEnumerable<TSource> WhereLead<TSource>(this IAsyncEnumerable<TSource> source, int offset, Func<TSource, TSource?, bool> predicate)
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, bool> | predicate | A function which accepts the current and subsequent (lead) element (in that order) to test for a condition. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Remarks
For elements of the sequence that are less than offset
items from the end, default(TSource
?) is used as the lead value.
This operator evaluates in a deferred and streaming manner.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
WhereLead<TSource>(IAsyncEnumerable<TSource>, int, Func<TSource, TSource?, ValueTask<bool>>)
Filters a sequence of values based on a predicate evaluated on the current value and a leading value.
Declaration
public static IAsyncEnumerable<TSource> WhereLead<TSource>(this IAsyncEnumerable<TSource> source, int offset, Func<TSource, TSource?, ValueTask<bool>> predicate)
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, ValueTask<bool>> | predicate | A function which accepts the current and subsequent (lead) element (in that order) to test for a condition. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Remarks
For elements of the sequence that are less than offset
items from the end, default(TSource
?) is used as the lead value.
This operator evaluates in a deferred and streaming manner.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
WhereLead<TSource>(IAsyncEnumerable<TSource>, int, TSource, Func<TSource, TSource, bool>)
Filters a sequence of values based on a predicate evaluated on the current value and a leading value.
Declaration
public static IAsyncEnumerable<TSource> WhereLead<TSource>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLeadValue, Func<TSource, TSource, bool> predicate)
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, bool> | predicate | A function which accepts the current and subsequent (lead) element (in that order) to test for a condition. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Remarks
This operator evaluates in a deferred and streaming manner.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
WhereLead<TSource>(IAsyncEnumerable<TSource>, int, TSource, Func<TSource, TSource, ValueTask<bool>>)
Filters a sequence of values based on a predicate evaluated on the current value and a leading value.
Declaration
public static IAsyncEnumerable<TSource> WhereLead<TSource>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLeadValue, Func<TSource, TSource, ValueTask<bool>> predicate)
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<bool>> | predicate | A function which accepts the current and subsequent (lead) element (in that order) to test for a condition. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the source sequence. |
Remarks
This operator evaluates in a deferred and streaming manner.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|