/* * Main authors: * Christian Schulte * Gabor Szokoli * * Copyright: * Christian Schulte, 2002 * Gabor Szokoli, 2003 * * Last modified: * $Date: 2006-08-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $ * $Revision: 3512 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * See the file "LICENSE" for information on usage and * redistribution of this file, and for a * DISCLAIMER OF ALL WARRANTIES. * */ #include "gecode/int/distinct.hh" namespace Gecode { using namespace Int; void distinct(Space* home, const IntVarArgs& x, IntConLevel icl) { if (x.same()) throw ArgumentSame("Int::distinct"); if (home->failed()) return; ViewArray xv(home,x); switch (icl) { case ICL_BND: GECODE_ES_FAIL(home,Distinct::Bnd::post(home,xv)); break; case ICL_DOM: GECODE_ES_FAIL(home,Distinct::Dom::post(home,xv)); break; default: GECODE_ES_FAIL(home,Distinct::Val::post(home,xv)); } } void distinct(Space* home, const IntArgs& c, const IntVarArgs& x, IntConLevel icl) { if (x.same()) throw ArgumentSame("Int::distinct"); if (c.size() != x.size()) throw ArgumentSizeMismatch("Int::distinct"); if (home->failed()) return; ViewArray cx(home,x.size()); for (int i = c.size(); i--; ) if ((c[i] < Limits::Int::int_min) || (c[i] > Limits::Int::int_max)) throw NumericalOverflow("Int::distinct"); else cx[i].init(x[i],c[i]); switch (icl) { case ICL_BND: GECODE_ES_FAIL(home,Distinct::Bnd::post(home,cx)); break; case ICL_DOM: GECODE_ES_FAIL(home,Distinct::Dom::post(home,cx)); break; default: GECODE_ES_FAIL(home,Distinct::Val::post(home,cx)); } } } // STATISTICS: int-post