public static IEnumerable<TResult> Batch<TSource, TResult>(
this IEnumerable<TSource> source,
int size,
ArrayPool<TSource> pool,
Func<ICurrentBuffer<TSource>, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function Batch(Of TSource, TResult) (
source As IEnumerable(Of TSource),
size As Integer,
pool As ArrayPool(Of TSource),
resultSelector As Func(Of ICurrentBuffer(Of TSource), TResult)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename TSource, typename TResult>
static IEnumerable<TResult>^ Batch(
IEnumerable<TSource>^ source,
int size,
ArrayPool<TSource>^ pool,
Func<ICurrentBuffer<TSource>^, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member Batch :
source : IEnumerable<'TSource> *
size : int *
pool : ArrayPool<'TSource> *
resultSelector : Func<ICurrentBuffer<'TSource>, 'TResult> -> IEnumerable<'TResult>
This operator uses deferred execution and streams its results (however, each bucket provided to resultSelector is buffered).
Each bucket is backed by a rented array that may be at least size in length.
When more than one bucket is produced, all buckets except the last is guaranteed to have size elements. The last bucket may be smaller depending on the remaining elements in the source sequence.
Each bucket is pre-allocated to size elements. If size is set to a very large value, e.g. MaxValue to effectively disable batching by just hoping for a single bucket, then it can lead to memory exhaustion (OutOfMemoryException).