Generated on Wed Jan 4 17:49:09 2006 for Gecode by doxygen 1.4.6

distinct.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *     Gabor Szokoli <szokoli@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2002
00008  *     Gabor Szokoli, 2003
00009  *
00010  *  Last modified:
00011  *     $Date: 2005-07-28 22:52:19 +0200 (Thu, 28 Jul 2005) $ by $Author: schulte $
00012  *     $Revision: 2072 $
00013  *
00014  *  This file is part of Gecode, the generic constraint
00015  *  development environment:
00016  *     http://www.gecode.org
00017  *
00018  *  See the file "LICENSE" for information on usage and
00019  *  redistribution of this file, and for a
00020  *     DISCLAIMER OF ALL WARRANTIES.
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 // STATISTICS: int-post
00073