CountableIteratorIterator

Class
extends IteratorIterator
implements Countable

Provides an iterator wrapper that is also countable.

Description

This class SHALL extend IteratorIterator to decorate an existing iterator while exposing counting behavior through the composed trait. The wrapped iterator MUST be compatible with the expectations of IteratorIterator, and consumers SHOULD rely on this class when they need both traversal and count semantics from a single object.

Table of Contents

Interfaces

Methods

count()

Counts the number of elements exposed by the inner iterator.

 : int
Methods

count()

Public

Counts the number of elements exposed by the inner iterator.

public count() : int

Description

If the inner iterator implements 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 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 values
int

Description

the total number of elements available from the inner iterator