EsSequenceableCollectionIterator
Description
A specialized <EsCollectionIterator> optimized for iterating over a <SequenceableCollection>. With a <Collection>, we can only guarantee a #do: method so a co-routine must be used during the #do: looping to adapt it to iterators. A sequenceable collection supports indexing, so we only need to keep track of the current index.
Instance State
• collection: <SequenceableCollection>
• index: <Integer>
• atEnd: <Boolean>
Class Methods
on:
Answer a new iterator over @aSequenceableCollection
Arguments:
aSequenceableCollection - <SequenceableCollection>
Answers:
<EsSequenceableCollectionIterator>
Instance Methods
current
The current element.
If the iterator has not yet been moved to the first element (#moveNext has not been called yet),
or if the iterator has been moved past the last element. (#moveNext has answered false),
then @current is unspecified.
The #current getter should keep its value until the next call to #moveNext, even if an underlying collection changes.
After a successful call to #moveNext, the user doesn't need to cache the current value, but can keep reading it from the iterator.
Answers:
<Object>
moveNext
Advances the iterator to the next element of the iteration.
Should be called before reading @current.
If the call to #moveNext answers `true`,
then @current will contain the next element of the iteration
until #moveNext is called again.
If the call answers `false`, there are no further elements
and @current should not be used any more.
It is safe to call #moveNext after it has already answered `false`,
but it must keep returning `false` and not have any other effect.
A call to #moveNext may raise an exception for various reasons,
including a concurrent change to an underlying collection.
If that happens, the iterator may be in an inconsistent
state, and any further behavior of the iterator is unspecified,
including the effect of reading @current.
Answers:
<Boolean>
Last modified date: 04/21/2022