Skip to content

CountableIterator

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

Provides a base iterator implementation that is also countable.

This abstract class SHALL be used as a foundation for iterators that need to expose counting behavior while remaining compatible with the standard

  • See: \Iterator contract. Implementations MUST preserve iterator semantics, and consumers SHOULD expect the counting logic to operate over the same sequence that is exposed during normal iteration.

  • Full name: \FastForward\Iterator\CountableIterator
  • This class implements: Iterator, Countable
  • This class is an Abstract class

Methods

count

Counts the number of elements available in the iterator.

public count(): int

This 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


Clone this wiki locally