Conditional Java SequenceIterator Methods

The following conditional SequenceIterator methods apply the object's boolean sequence to the input sequence(s). These methods are of the following types:

The following methods are available:

public SequenceIterator iif(SequenceIterator then, SequenceIterator otherwise, boolean lazy)

Chooses the element of the then sequence or the otherwise sequence depending on the boolean value of the element of the object's condition sequence. All three sequences are traversed at the same speed (if the element of the then sequence is used, then the element of the otherwise sequence is skipped and vice versa). Please see the Ternary Operations page for further details.

public SequenceIterator filter(SequenceIterator cond)

Returns a sequence of the same type as input with only the elements corresponding to true elements in the object's condition sequence.

public SequenceIterator filterPos()

Returns an integer sequence with the positions of the true elements in the object's condition sequence.

Example

The following code snippet demonstrates a conditional method:

    cursor = con.cursor("Quote", "by_sym")
    for quote in cursor:
        ...
        last = quote.day.last();
        dayit = quote.day.search(DMY(1,MONTH(last),YEAR(last)),
                exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE,
                last,
                exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE)
        openit,closeit = dayit.project('open', 'close')
        gtit = closeit.gt(openit)
        filtit = gtit.filter(dayit)
        ...