CountableIterator

Class
implements Iterator Countable
Abstract: Yes

Provides a base iterator implementation that is also countable.

Description

This abstract class SHALL be used as a foundation for iterators that need to expose counting behavior while remaining compatible with the standard 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.

Table of Contents

Interfaces

Methods

count()

Counts the number of elements available in the iterator.

 : int
Methods

count()

Public

Counts the number of elements available in the iterator.

public count() : int

Description

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 values
int

Description

the total number of elements exposed by the iterator