dartora

Iteration

Iteration is the foundation of Dartora’s collection framework. It defines a windowed view into an underlying sequence and supports most of the operations of Dart’s built‑in Iterable and List classes without copying data. The concept is split into two parts:

Windowing

Every Iteration has two offsets that determine which portion of the source collection is visible:

The visible length of the iteration is length = (sourceLength − startIndex) − indexTake. Concrete implementations must provide the sourceLength getter and the sourceGet(int sourceIndex) method to retrieve the raw element from the source.

Core properties

Property Meaning
sourceLength Length of the underlying sequence. Implementations may override this for efficiency.
startIndex Number of hidden elements at the beginning of the source.
indexTake Number of hidden elements at the end of the source.
length Visible number of elements, computed from sourceLength, startIndex and indexTake.
isEmpty / isNotEmpty Whether there are zero or at least one visible element.

Element retrieval

Searching and predicates

Iteration implements several search methods analogous to those on List:

Reduction and string conversion

Mapping and slicing

Iteration supports creating new views rather than copying data:

Type conversion

Concrete implementations

The abstract API is realised by several concrete classes:

The Iteration mixin provides default implementations for most methods, but subclasses may override them for efficiency. For example, IterationList overrides sourceGet to index directly into its underlying list, and LargeIterable overrides map to compose transformation functions instead of materialising intermediate sequences.