/* * Main authors: * Guido Tack * * Contributing authors: * Gabor Szokoli * * Copyright: * Guido Tack, 2004, 2005 * * Last modified: * $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $ * $Revision: 3188 $ * * 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/set.hh" #include "gecode/iter.hh" #include "gecode/set/rel.hh" #include "gecode/set/rel-op.hh" namespace Gecode { using namespace Gecode::Set; using namespace Gecode::Set::Rel; using namespace Gecode::Set::RelOp; void rel(Space* home, SetVar x, SetOpType op, SetVar y, SetRelType r, SetVar z) { rel_op_post(home, x, op, y, r, z); } void rel(Space* home, SetOpType op, const SetVarArgs& x, SetVar y) { if (home->failed()) return; ViewArray xa(home,x); switch(op) { case SOT_UNION: GECODE_ES_FAIL(home,(RelOp::UnionN::post(home, xa, y))); break; case SOT_DUNION: GECODE_ES_FAIL(home, (RelOp::PartitionN::post(home, xa, y))); break; case SOT_INTER: { GECODE_ES_FAIL(home, (RelOp::IntersectionN ::post(home, xa, y))); } break; case SOT_MINUS: throw InvalidRelation("rel minus"); break; } } void rel(Space* home, SetOpType op, const IntVarArgs& x, SetVar y) { if (home->failed()) return; ViewArray xa(home,x.size()); for (int i=x.size(); i--;) { Int::IntView iv(x[i]); SingletonView sv(iv); xa[i] = sv; } switch(op) { case SOT_UNION: GECODE_ES_FAIL(home,(RelOp::UnionN ::post(home, xa, y))); break; case SOT_DUNION: GECODE_ES_FAIL(home,(RelOp::PartitionN ::post(home, xa, y))); break; case SOT_INTER: GECODE_ES_FAIL(home, (RelOp::IntersectionN ::post(home, xa, y))); break; case SOT_MINUS: throw InvalidRelation("rel minus"); break; } } } // STATISTICS: set-post