On 5/14/07, Kilian Sprotte <[EMAIL PROTECTED]> wrote:
At some point, I know that x0 is assigned. What I would like to do is to filter the domain of x1 using a given predicate function.if (x0.assigned()) { IntVarValues r1(x1); while (r1()) { if (!my_predicate(x0.val(), r1.val())) GECODE_ME_CHECK(x1.nq(home, r1.val())) ++r1; } return ES_SUBSUMED; It does not seem to be a good idea however to alter the view x1 while iterating over it...(is it true that this should not be done/will cause problems?)
As you've discovered, one should not modify a view while iterating over it.
Hhm, could anyone give me a hint, what I could use in order to do this safely?
A solution that works efficiently in many cases is to store the values to remove on a stack, and then remove them after iteration over the view is finished. A cheap simple stack can be obtained using the GECODE_AUTOARRAY macro and a counter of the number of values on the stack. This pattern is quite common, it occurs for example in distinct and regular. Hope this helps, Mikael -- Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/ _______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users
