typeOfNext
Returns an integer expression that represents the type of the interval variable that is next.
Syntax
intExpr typeOfNext(sequenceVar seq, intervalVar interval, int lastValue = 0, int absentValue = 0)
Parameters
-
seq: sequence variable. -
interval: interval variable. -
lastValue: value to return if interval variableintervalis the last one inseq. -
absentValue: value to return if interval variableintervalbecomes absent.
Description
This function returns an integer expression that represents the type of the interval variable
that is next to interval in sequence variable seq. When interval is present and is
the last interval of seq, it returns the constant integer value lastValue (zero by default).
When interval is absent, it returns the constant integer value absentValue (zero by default).
Example
a = intervalVar(size=5);
bx = intervalVar(size=6);
by = intervalVar(size=6);
c = intervalVar(optional, size=7);
// A sequence variable defined on {a, bx, by, c} with types {0, 1, 1, 2}
seq = sequenceVar([a, bx, by, c], [0, 1, 1, 2]);
// The interval variables of the sequence cannot overlap
noOverlap(seq);
// If interval variable a is not the last one, the type of the interval next to a should be 1
// Note that a can be last (1 == 1)
typeOfNext(seq, a, 1) == 1;
// If interval variable c is present, it cannot be the last one (1 == 1) and the type value of the interval next
// to c should not be 1. Note that interval variable c can be absent (0 != 1).
typeOfNext(seq, c, 1, 0) != 1;
A possible value for the sequence variable in this problem is (c -> a -> bx -> by).
Another possible value with c absent is (a -> bx -> by).
Requirements
-
intervalshould be an interval variable of sequence variableseq.