Library / Core interfaces / Collections and iteration / ObjectIterator
ObjectIterator
ObjectIterator OF T — extends Iterator with by-reference navigation
over a HEAP-CLASS element type. The object peer of ReferenceIterator:
where ReferenceIterator's bound admits only Cloneable primitives,
ObjectIterator admits any class, so a collection whose logical
element is a synthesized class instance (a per-position VIEW — e.g.
a DataFrame yielding a Row built from its stored columns) can be
FOR e IN coll-iterable. Because the source may not STORE the
element (it synthesizes it), the concrete iterator OWNS the current
element in an internal slot and hands back a non-owning REFERENCE
into that slot; the reference is valid until the next advance, on
which the slot is refreshed. The FOR-IN loop borrows it for the
iteration exactly as it borrows a ReferenceIterator's referent —
so next() lowers to REFERENCE T (a T*) on both this interface
and its implementers, with none of the value-form covariance seam.
Methods 2
MODIFY METHOD next() RETURNS | REFERENCE Tmodifies
2.0 pipe-XOR shape: a successful navigation refreshes the
iterator's owned slot and populates value with a non-owning
reference into it; end-of-iteration populates s with FAILURE.
METHOD peek() RETURNS | REFERENCE Treads
peek is non-consuming: the reference to the current slot without advancing. Same pipe-XOR shape as next().