Example #1
0
 forceinline ExecStatus
 LinkMulti::post(Home home, ViewArray<BoolView>& x, IntView y, int o) {
   int n=x.size();
   GECODE_ME_CHECK(y.gq(home,o));
   GECODE_ME_CHECK(y.lq(home,o+n-1));
   assert(n > 0);
   if (n == 1) {
     GECODE_ME_CHECK(x[0].one(home));
     assert(y.val() == o);
   } else if (y.assigned()) {
     int j=y.val()-o;
     GECODE_ME_CHECK(x[j].one(home));
     for (int i=0; i<j; i++)
       GECODE_ME_CHECK(x[i].zero(home));
     for (int i=j+1; i<n; i++)
       GECODE_ME_CHECK(x[i].zero(home));
   } else {
     for (int i=n; i--; )
       if (x[i].one()) {
         for (int j=0; j<i; j++)
           GECODE_ME_CHECK(x[j].zero(home));
         for (int j=i+1; j<n; j++)
           GECODE_ME_CHECK(x[j].zero(home));
         GECODE_ME_CHECK(y.eq(home,o+i));
         return ES_OK;
       } else if (x[i].zero()) {
         GECODE_ME_CHECK(y.nq(home,o+i));
       }
     (void) new (home) LinkMulti(home,x,y,o);
   }
   return ES_OK;
 }
Example #2
0
 ExecStatus
 TellCache::tell(Space& home, IntView x) {
   if (_eq == -2) {
     return ES_FAILED;
   } else if (_eq >= 0) {
     GECODE_ME_CHECK(x.eq(home,_eq));
   }
   Iter::Values::Array nqi(_nq, _n_nq);
   GECODE_ME_CHECK(x.minus_v(home, nqi));
   _n_nq=0; _eq=-1;
   return ES_OK;
 }