-
-
Notifications
You must be signed in to change notification settings - Fork 0
ChunkedIteratorAggregate
Class ChunkedIteratorAggregate.
Splits an iterable into fixed-size chunks.
This iterator wraps a Traversable and groups elements into subarrays
of a fixed size. If the total number of elements is not a multiple of
the chunk size, the last chunk may contain fewer elements.
- Full name:
\FastForward\Iterator\ChunkedIteratorAggregate - Parent class:
\FastForward\Iterator\CountableIteratorAggregate
Initializes the ChunkedIteratorAggregate.
public __construct(iterable $iterator, int $chunkSize): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$iterator |
iterable | the iterator containing values to be chunked |
$chunkSize |
int | the number of elements per chunk (must be >= 1) |
Retrieves an iterator that yields arrays containing elements in chunks.
public getIterator(): \Traversable<int,array<int,mixed>>The iteration groups elements from the original iterator into
subarrays of $chunkSize elements each.
Return Value:
the iterator yielding chunked arrays
Counts the number of elements in the iterable.
public count(): intIf the inner iterator implements Countable, it uses that. Otherwise, it counts the elements by iterating through them.
Return Value:
the number of elements in the iterable