Iterator
Walking the structure without exposing it. Kotlin ships this as Iterable and Sequence, so the point of studying it is the contract – who owns the cursor, what happens when the collection changes mid-walk – not the implementation.
Structure
classDiagram
class Aggregate {
<<interface>>
+iterator() Iterator
}
class ConcreteAggregate {
+iterator() Iterator
}
class Iterator {
<<interface>>
+hasNext() Boolean
+next() T
}
class ConcreteIterator {
-cursor
}
Aggregate <|.. ConcreteAggregate
Iterator <|.. ConcreteIterator
ConcreteAggregate ..> ConcreteIterator : creates