Skip to main content

%Library.Iterator

%Library.Iterator defines a standard interface for iterators. It is compatible with legacy iterators that extend %Iterator.AbstractIterator.

This interface supports three common code patterns.

set array = [0,1,2,3,4]
set iterator = array.iterator()
while iterator.hasNext() {
    set next = iterator.next()
    // do something with next.key and next.value
}
set array = [0,1,2,3,4]
set iterator = array.iterator()
for {
    set next = iterator.next()
    quit:next=""
    // do something with next.key and next.value
}
set array = [0,1,2,3,4]
set iterator = array.iterator()
for {
    quit:'iterator.%GetNext(.key,.value)
    // do something with key and value
}

Implementors are expected to override next(). %GetNext() is present for compatibility with %Iterator.AbstractIterator

Property Inventory

Method Inventory

Properties

property _hasNext as %Boolean [ InitialExpression = 0 ];
True if "_next" contains the next member at the current iterator position.
Property methods: _hasNextDisplayToLogical(), _hasNextGet(), _hasNextIsValid(), _hasNextLogicalToDisplay(), _hasNextNormalize(), _hasNextSet()
property _next as %Library.DynamicObject [ InitialExpression = $$$NULLOREF ];
This property holds the member of the set at the current iterator position.
Property methods: _nextGet(), _nextGetObject(), _nextGetObjectId(), _nextGetSwizzled(), _nextIsValid(), _nextNewObject(), _nextSet(), _nextSetObject(), _nextSetObjectId(), _nextUnSwizzle()

Methods

abstract method %GetNext(Output key As %RawString, Output value As %RawString) as %Integer
Present only for compatibility with %Iterator.AbstractIterator
method hasNext() as %Boolean

Return true if there is member if the iterator were to be advanced by invoking next()

Returns false if the iterator is positioned at the end of the set

Advance the iterator to the next position and return the current member or, if the iterator's position is after the end of the set then null

Inherited Members

Inherited Methods

FeedbackOpens in a new tab