Method WhereLag
View SourceWhereLag<TSource>(IAsyncEnumerable<TSource>, int, Func<TSource, TSource?, bool>)
Filters a sequence of values based on a predicate evaluated on the current value and a lagging value.
Declaration
public static IAsyncEnumerable<TSource> WhereLag<TSource>(this IAsyncEnumerable<TSource> source, int offset, Func<TSource, TSource?, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | An IAsyncEnumerable<T> to filter. |
int | offset | The offset (expressed as a positive number) by which to lag each element of the sequence. |
Func<TSource, TSource, bool> | predicate | A function which accepts the current and lagged 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 Lag value.
This operator evaluates in a deferred and streaming manner.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
WhereLag<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 lagging value.
Declaration
public static IAsyncEnumerable<TSource> WhereLag<TSource>(this IAsyncEnumerable<TSource> source, int offset, Func<TSource, TSource?, ValueTask<bool>> predicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | An IAsyncEnumerable<T> to filter. |
int | offset | The offset (expressed as a positive number) by which to lag each element of the sequence. |
Func<TSource, TSource, ValueTask<bool>> | predicate | A function which accepts the current and lagged 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 Lag value.
This operator evaluates in a deferred and streaming manner.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
WhereLag<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 lagging value.
Declaration
public static IAsyncEnumerable<TSource> WhereLag<TSource>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLagValue, Func<TSource, TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | An IAsyncEnumerable<T> to filter. |
int | offset | The offset (expressed as a positive number) by which to lag each element of the sequence. |
TSource | defaultLagValue | A default value supplied for the lagged element when none is available |
Func<TSource, TSource, bool> | predicate | A function which accepts the current and lagged 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 |
|
WhereLag<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 lagging value.
Declaration
public static IAsyncEnumerable<TSource> WhereLag<TSource>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLagValue, Func<TSource, TSource, ValueTask<bool>> predicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | An IAsyncEnumerable<T> to filter. |
int | offset | The offset (expressed as a positive number) by which to lag each element of the sequence. |
TSource | defaultLagValue | A default value supplied for the lagged element when none is available |
Func<TSource, TSource, ValueTask<bool>> | predicate | A function which accepts the current and lagged 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 |
|