Skip to content

CountableIteratorAggregate

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

Provides a base implementation for iterator aggregate objects that are also countable.

This abstract class SHALL serve as a reusable foundation for concrete iterator aggregate implementations that expose a traversable iterator and require count-related behavior. Implementations MUST provide a valid iterator through

  • See: \FastForward\Iterator\getIterator(), and that iterator SHOULD be suitable for reuse by the count-related logic provided through the composed trait.

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

Inherited methods

count

Counts the number of elements exposed by the inner iterator.

public count(): int

If 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


Clone this wiki locally