Method Buffer
Buffer<TSource>(IAsyncEnumerable<TSource>, int)
Generates a sequence of non-overlapping adjacent buffers over the source sequence.
Declaration
public static IAsyncEnumerable<IList<TSource>> Buffer<TSource>(this IAsyncEnumerable<TSource> source, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | Source sequence. |
| int | count | Number of elements for allocated buffers. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<IList<TSource>> | Sequence of buffers containing source sequence elements. |
Type Parameters
| Name | Description |
|---|---|
| TSource | Source sequence element type. |
Remarks
A chunk can contain fewer elements than count, specifically the final buffer of source.
This method is a synonym for Batch<TSource>(IAsyncEnumerable<TSource>, int).
Returned subsequences are buffered, but the overall operation is streamed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
Buffer<TSource>(IAsyncEnumerable<TSource>, int, int)
Generates a sequence of buffers over the source sequence, with specified length and possible overlap.
Declaration
public static IAsyncEnumerable<IList<TSource>> Buffer<TSource>(this IAsyncEnumerable<TSource> source, int count, int skip)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | Source sequence. |
| int | count | Number of elements for allocated buffers. |
| int | skip | Number of elements to skip between the start of consecutive buffers. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<IList<TSource>> | Sequence of buffers containing source sequence elements. |
Type Parameters
| Name | Description |
|---|---|
| TSource | Source sequence element type. |
Remarks
A chunk can contain fewer elements than count, specifically the final buffers of source.
Returned subsequences are buffered, but the overall operation is streamed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|