-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 exposed by the inner iterator.
public count(): intIf the inner iterator implements
-
See: \Countable, this method SHALL return the value provided by that implementation. Otherwise, it MUST count elements by iterating over the iterator. If the inner iterator is not cloneable, this method SHALL wrap the current object in an
-
See: \IteratorIterator instance and count through that wrapper to avoid performing an invalid clone operation. If the inner iterator is cloneable, this method SHOULD count over a clone so that the original iterator state is preserved as much as possible.
Return Value:
the total number of elements available from the inner iterator