-
-
Notifications
You must be signed in to change notification settings - Fork 0
UniqueIteratorIterator
Class UniqueIteratorIterator.
Filters duplicate values from an iterator, ensuring uniqueness.
This iterator allows traversing an iterable while maintaining a record of seen values, returning only the first occurrence of each unique value. Subsequent occurrences are skipped.
- Full name:
\FastForward\Iterator\UniqueIteratorIterator - Parent class:
\FastForward\Iterator\CountableIteratorIterator
Initializes the UniqueIteratorIterator.
public __construct(iterable $iterator, bool $strict = true, bool $caseSensitive = true): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$iterator |
iterable | the iterator to filter for unique values |
$strict |
bool | whether to use strict comparison (default: true) |
$caseSensitive |
bool | whether to use case-sensitive comparison (default: true) |
Retrieves the normalized sequential key for the current unique element.
public key(): intReturn Value:
the zero-based position of the current unique value
Advances to the next unique element.
public next(): voidResets the iterator and clears the seen values.
public rewind(): voidCounts 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