distinct.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "int/distinct.hh"
00025
00026 namespace Gecode {
00027
00028 using namespace Int;
00029
00030 void
00031 distinct(Space* home, const IntVarArgs& x, IntConLevel icl) {
00032 if (home->failed()) return;
00033 ViewArray<IntView> xv(home,x);
00034 switch (icl) {
00035 case ICL_BND:
00036 GECODE_ES_FAIL(home,Distinct::Bnd<IntView>::post(home,xv));
00037 break;
00038 case ICL_DOM:
00039 GECODE_ES_FAIL(home,Distinct::Dom<IntView>::post(home,xv));
00040 break;
00041 default:
00042 GECODE_ES_FAIL(home,Distinct::Val<IntView>::post(home,xv));
00043 }
00044 }
00045
00046 void
00047 distinct(Space* home, const IntArgs& c, const IntVarArgs& x,
00048 IntConLevel icl) {
00049 if (c.size() != x.size())
00050 throw ArgumentSizeMismatch("Int::distinct");
00051 if (home->failed()) return;
00052 ViewArray<OffsetView> cx(home,x.size());
00053 for (int i = c.size(); i--; )
00054 if ((c[i] < Limits::Int::int_min) || (c[i] > Limits::Int::int_max))
00055 throw NumericalOverflow("Int::distinct");
00056 else
00057 cx[i].init(x[i],c[i]);
00058 switch (icl) {
00059 case ICL_BND:
00060 GECODE_ES_FAIL(home,Distinct::Bnd<OffsetView>::post(home,cx));
00061 break;
00062 case ICL_DOM:
00063 GECODE_ES_FAIL(home,Distinct::Dom<OffsetView>::post(home,cx));
00064 break;
00065 default:
00066 GECODE_ES_FAIL(home,Distinct::Val<OffsetView>::post(home,cx));
00067 }
00068 }
00069
00070 }
00071
00072
00073