| 41 | namespace Gecode { |
| 42 | |
| 43 | void |
| 44 | unary(Home home, const IntVarArgs& s, const IntArgs& p, IntPropLevel ipl) { |
| 45 | using namespace Gecode::Int; |
| 46 | using namespace Gecode::Int::Unary; |
| 47 | if (same(s)) |
| 48 | throw Int::ArgumentSame("Int::unary"); |
| 49 | if (s.size() != p.size()) |
| 50 | throw Int::ArgumentSizeMismatch("Int::unary"); |
| 51 | for (int i=0; i<p.size(); i++) { |
| 52 | Int::Limits::nonnegative(p[i],"Int::unary"); |
| 53 | Int::Limits::check(static_cast<long long int>(s[i].max()) + p[i], |
| 54 | "Int::unary"); |
| 55 | } |
| 56 | GECODE_POST; |
| 57 | bool allOne = true; |
| 58 | for (int i=0; i<p.size(); i++) { |
| 59 | if (p[i] != 1) { |
| 60 | allOne = false; |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | if (allOne) { |
| 65 | ViewArray<IntView> xv(home,s); |
| 66 | switch (vbd(ipl)) { |
| 67 | case IPL_BND: |
| 68 | GECODE_ES_FAIL(Distinct::Bnd<IntView>::post(home,xv)); |
| 69 | break; |
| 70 | case IPL_DOM: |
| 71 | GECODE_ES_FAIL(Distinct::Dom<IntView>::post(home,xv)); |
| 72 | break; |
| 73 | default: |
| 74 | GECODE_ES_FAIL(Distinct::Val<IntView>::post(home,xv)); |
| 75 | } |
| 76 | } else { |
| 77 | TaskArray<ManFixPTask> t(home,s.size()); |
| 78 | for (int i=0; i<s.size(); i++) |
| 79 | t[i].init(s[i],p[i]); |
| 80 | GECODE_ES_FAIL(manpost(home,t,ipl)); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | unary(Home home, const TaskTypeArgs& t, |
no test coverage detected