forceinline TakesStatus takes(const View& x, const IntSet& s) { if ((x.max() < s.min()) || (x.min() > s.max())) return TS_NO; ViewRanges<View> ix(x); IntSetRanges is(s); switch (Iter::Ranges::compare(ix,is)) { case Iter::Ranges::CS_SUBSET: return TS_YES; case Iter::Ranges::CS_DISJOINT: return TS_NO; case Iter::Ranges::CS_NONE: return TS_MAYBE; default: GECODE_NEVER; } return TS_MAYBE; }
forceinline int ValSelNearMinMax<View,min>::val(const Space&, View x, int i) { int n = c[i]; if (x.max() <= n) return x.max(); if (x.min() >= n) return x.min(); if (x.range()) return n; ViewRanges<View> r(x); int pmax; do { pmax=r.max(); ++r; } while (r.max() < n); assert(r()); if ((pmax >= n) || (r.min() <= n)) return n; assert((pmax < n) && (n < r.min())); unsigned int dmin = static_cast<unsigned int>(n - pmax); unsigned int dmax = static_cast<unsigned int>(r.min() - n); if (dmin == dmax) return min ? pmax : r.min(); else if (dmin < dmax) return pmax; else return r.min(); }
forceinline bool any(const View& x) { return (x.min() <= 0) && (x.max() >= 0); }
forceinline bool pos(const View& x) { return x.min() > 0; }
forceinline int ValSelAvg<View>::val(const Space&, View x, int) { return (x.width() == 2U) ? x.min() : ((x.min()+x.max()) / 2); }
forceinline int ValSelMin<View>::val(const Space&, View x, int) { return x.min(); }
forceinline int ValMin<View>::val(Space&, View x) const { return x.min(); }
forceinline int ValSplitMin<View>::val(Space&, View x) const { return (x.width() == 2) ? x.min() : ((x.min()+x.max()) / 2); }
forceinline RelTest rtest_eq_bnd(View x, int n) { if ((n > x.max()) || (n < x.min())) return RT_FALSE; return x.assigned() ? RT_TRUE : RT_MAYBE; }
forceinline RelTest rtest_eq_bnd(View x, View y) { if ((x.min() > y.max()) || (x.max() < y.min())) return RT_FALSE; return (x.assigned() && y.assigned()) ? RT_TRUE : RT_MAYBE; }
forceinline RelTest rtest_gr(View x, View y) { if (x.max() <= y.min()) return RT_FALSE; if (x.min() > y.max()) return RT_TRUE; return RT_MAYBE; }
forceinline RelTest rtest_gr(View x, int n) { if (x.max() <= n) return RT_FALSE; if (x.min() > n) return RT_TRUE; return RT_MAYBE; }