-
-
Notifications
You must be signed in to change notification settings - Fork 0
InterleaveIteratorIterator
Interleaves elements from multiple iterators in a round-robin fashion.
This iterator alternates between multiple traversable sources, returning one element from each before cycling back to the first. The iteration stops once all iterators are exhausted.
- Full name:
\FastForward\Iterator\InterleaveIteratorIterator - Parent class:
\FastForward\Iterator\CountableIterator
Initializes the InterleaveIteratorIterator.
public __construct(iterable $iterators): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$iterators |
iterable | The iterators to be interleaved. |
Throws:
if no iterators are provided
Retrieves the current element from the active iterator.
public current(): mixedReturn Value:
the current element
Retrieves the current key from the active iterator or a normalized sequential key.
public key(): string|intIf the active iterator's current key is a string, it is returned directly. Otherwise, a normalized sequential numeric key is returned based on the position of yielded values without string keys.
Return Value:
the current key
public next(): voidChecks if at least one iterator still has elements.
public valid(): boolReturn Value:
true if there are remaining elements, false otherwise
public rewind(): voidCounts the number of elements available in the iterator.
public count(): intThis method MUST count the elements by iterating over a clone of the current iterator instance so that the active iterator state of the original object is not modified during the counting process. Concrete implementations SHOULD therefore remain safely cloneable whenever this behavior is expected to be used.
Return Value:
the total number of elements exposed by the iterator