CountableIteratorAggregate
Provides a base implementation for iterator aggregate objects that are also countable.
Description
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 getIterator(), and that iterator SHOULD be suitable for reuse by the count-related logic provided through the composed trait.
Interfaces
Methods
Counts the number of elements exposed by the inner iterator.
Returns the inner traversable iterator used by the aggregate.
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
Description
the total number of elements available from the inner iterator
Returns the inner traversable iterator used by the aggregate.
private
getInnerIterator() : Traversable
Description
This method SHALL proxy the iterator returned by getIterator() without altering its semantics or traversal behavior. Consumers of this method MUST receive the same traversable instance or equivalent traversable representation exposed by the aggregate. This method SHOULD remain private because it exists only to support the internal collaboration between this class and its trait-based behavior.
Return values
Description
the traversable iterator exposed by the aggregate implementation