irisnative.iterator

class irisnative.iterator

An iterator over the immediate children of a global node.

The iterator can be set to move forwards or backwards, and to return the subscript and value, just the subscript, or just the value for each node in the iteration. This is similar to using the $ORDER function in ObjectScript.

Methods

iterator.next Return the next subscript and/or value in the iteration.
iterator.startFrom Set the starting position and return the iterator.
iterator.reversed Reverse the direction and return the iterator.
iterator.subscripts Set the iterator to return subscripts only and return the iterator.
iterator.values Set the iterator to return values only and return the iterator.
iterator.items Set the iterator to return subscripts & values and return the iterator.
iterator.next()

Return the next subscript and/or value in the iteration.

next()

Each call to this method may return: a tuple of the next subscript and value, just the subscript, or just the value, depending on the current setting. In the tuple case, the subscript is the first element and the value is the second. The subscript is a Unicode string and the value may be an Integer/Long, Unicode string, Float, or None.

Returns:next element in iteration
Return type:subscript, value, or tuple of subscript and value
iterator.startFrom()

Set the starting position and return the iterator.

startFrom(subscript)

Set the starting position to the specified subscript. After calling this method, use next() to advance the iterator to the next defined sub-node in alphabetic collating sequence. For example, for the following global and iterator:

^gbl(“a”)=11

^gbl(“b”)=22

^gbl(“e”)=55

itr=iris.iterator(“^gbl”)

The starting position may be a valid sub-node, in which case the next sub-node will be the next valid one.

itr.startFrom(“a”)

for sub, val in itr:

print(sub,”->”,val)

// prints: b -> 22; e -> 55

The starting position may also be an invalid sub-node, in which case the next sub-node will be the first valid one in alphabetic collating sequence after the given subscript.

itr.startFrom(“c”)

for sub, val in itr:

print(sub,”->”,val)

// prints: e -> 55

Calling this method with None as the argument is the same as using the default starting position, which is just before the first node, or just after the last node, depending on the iterator direction.

Parameters:subscript (Unicode string) – a single subscript indicating a starting position
Returns:The same iterator object.
Return type:irisnative.iterator
iterator.reversed()

Reverse the direction and return the iterator.

reversed()

Returns:The same iterator object.
Return type:irisnative.iterator
iterator.subscripts()

Set the iterator to return subscripts only and return the iterator.

subscripts()

Returns:The same iterator object.
Return type:irisnative.iterator
iterator.values()

Set the iterator to return values only and return the iterator.

values()

Returns:The same iterator object.
Return type:irisnative.iterator
iterator.items()

Set the iterator to return subscripts & values and return the iterator.

items()

Returns:The same iterator object.
Return type:irisnative.iterator