Iterator C Sequence Functions

Read Logical Elements

mco_seq_next_TYPE() extracts the next logical element from an iterator:

    MCO_RET mco_seq_next_TYPE(
        mco_seq_iterator_h iterator,
        mco_TYPE* value
    );

TYPE is one of the applicable suffixes described on the C Sequence Functions page. The function returns:

With RLE sequences, typed traversal expands physical runs. The number of successful logical reads is therefore independent of the storage representation.

Reset a Pipeline

Each iterator constructor installs a reset callback appropriate for the iterator and its operand tree. Call that callback to traverse the same pipeline again:

    MCO_RET rc;

    if (iterator.reset == NULL)
        rc = MCO_E_ILLEGAL_PARAM;
    else
        rc = iterator.reset(&iterator);

The following public functions implement standard reset callbacks. Application code normally does not select them directly; they are useful to code that implements a custom iterator:

mco_seq_reset_iterator()
Resets the local position and tile state of a source iterator.
mco_seq_reset_unary_iterator()
Resets a unary iterator and recursively invokes its operand's installed reset callback.
mco_seq_reset_binary_iterator()
Resets a binary iterator and recursively invokes both installed operand reset callbacks.

Example

    mco_seq_iterator_t high_iterator = { 0 };
    float high;
    MCO_RET rc;

    rc = Quote_high_iterator(&quote, &high_iterator);
    while (rc == MCO_S_OK)
    {
        rc = mco_seq_next_float(&high_iterator, &high);
        if (rc == MCO_S_OK)
            printf("%g\n", (double)high);
        else if (rc == MCO_E_SEQ_NULL_VALUE)
            rc = MCO_S_OK; /* Continue after the NULL element. */
    }
    if (rc == MCO_S_CURSOR_END)
        rc = MCO_S_OK;

For bulk extraction, including preservation of NULL bits, see mco_seq_get_TYPE() and mco_seq_get_nullable_TYPE() on the Sequence Manipulator C Functions page. For raw physical tile traversal, see Sequence Iterator.