Skip to content

RepeatableIteratorIterator

github-actions edited this page Mar 31, 2026 · 2 revisions

An iterator that enables repeated iteration over a finite subset of an infinite iterator.

This iterator wraps an Iterator and applies a LimitIterator over an InfiniteIterator, allowing a limited number of repeated iterations without modifying the underlying iterator.

It also implements Countable to return the number of elements available in the limited iteration.

Usage Example:


  • Full name: \FastForward\Iterator\RepeatableIteratorIterator
  • Parent class: LimitIterator
  • This class implements: Countable

Methods

__construct

Initializes the RepeatableIteratorIterator.

public __construct(iterable $iterator, int $limit, int $offset = 0): mixed

Parameters:

Parameter Type Description
$iterator iterable the iterator to be wrapped in an infinite loop
$limit int the maximum number of elements to iterate over per cycle
$offset int the starting offset within the iterator

count

Returns the number of elements that can be iterated per cycle.

public count(): int

Return Value:

the count of items in the limited iteration


Clone this wiki locally