CountableIterator
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.
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
Description
the total number of elements exposed by the iterator