Method CountDown
View SourceCountDown<TSource>(IAsyncEnumerable<TSource>, int)
Provides a countdown counter for a given count of elements at the tail of the sequence where zero always represents the last element, one represents the second-last element, two represents the third-last element and so on.
Declaration
public static IAsyncEnumerable<(TSource item, int? count)> CountDown<TSource>(this IAsyncEnumerable<TSource> source, int count)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
int | count | Count of tail elements of |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource item, int? count)> | A sequence of tuples of the element and it's count from the end of the sequence. |
Type Parameters
Name | Description |
---|---|
TSource | The type of elements of |
Remarks
This method uses deferred execution semantics and streams its results. At most, count
elements of the source sequence may be buffered at any one time unless source
is a collection
or a list.
This operator executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
CountDown<TSource, TResult>(IAsyncEnumerable<TSource>, int, Func<TSource, int?, TResult>)
Provides a countdown counter for a given count of elements at the tail of the sequence where zero always represents the last element, one represents the second-last element, two represents the third-last element and so on.
Declaration
public static IAsyncEnumerable<TResult> CountDown<TSource, TResult>(this IAsyncEnumerable<TSource> source, int count, Func<TSource, int?, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
int | count | Count of tail elements of |
Func<TSource, int?, TResult> | resultSelector | A function that receives the element and the current countdown value for the element and which returns those
mapped to a result returned in the resulting sequence. For elements before the last |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence of results returned by |
Type Parameters
Name | Description |
---|---|
TSource | The type of elements of |
TResult | The type of elements of the resulting sequence. |
Remarks
This method uses deferred execution semantics and streams its results. At most, count
elements of the source sequence may be buffered at any one time unless source
is a collection
or a list.
This operator executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|