Generated on Wed Nov 1 15:04:45 2006 for Gecode by doxygen 1.4.5

rel-op.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Contributing authors:
00006  *     Gabor Szokoli <szokoli@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Guido Tack, 2004, 2005
00010  *
00011  *  Last modified:
00012  *     $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
00013  *     $Revision: 3188 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  See the file "LICENSE" for information on usage and
00020  *  redistribution of this file, and for a
00021  *     DISCLAIMER OF ALL WARRANTIES.
00022  *
00023  */
00024 
00025 #include "gecode/set.hh"
00026 #include "gecode/iter.hh"
00027 #include "gecode/set/rel.hh"
00028 #include "gecode/set/rel-op.hh"
00029 
00030 namespace Gecode {
00031   using namespace Gecode::Set;
00032   using namespace Gecode::Set::Rel;
00033   using namespace Gecode::Set::RelOp;
00034 
00035   void
00036   rel(Space* home, SetVar x, SetOpType op, SetVar y, SetRelType r, SetVar z) {
00037     rel_op_post<SetView,SetView,SetView>(home, x, op, y, r, z);
00038   }
00039 
00040   void
00041   rel(Space* home, SetOpType op, const SetVarArgs& x, SetVar y) {
00042     if (home->failed()) return;
00043     ViewArray<SetView> xa(home,x);
00044     switch(op) {
00045     case SOT_UNION:
00046       GECODE_ES_FAIL(home,(RelOp::UnionN<SetView,SetView>::post(home, xa, y)));
00047       break;
00048     case SOT_DUNION:
00049       GECODE_ES_FAIL(home,
00050                      (RelOp::PartitionN<SetView,SetView>::post(home, xa, y)));
00051       break;
00052     case SOT_INTER:
00053       {
00054         GECODE_ES_FAIL(home,
00055                        (RelOp::IntersectionN<SetView,SetView>
00056                         ::post(home, xa, y)));
00057       }
00058       break;
00059     case SOT_MINUS:
00060       throw InvalidRelation("rel minus");
00061       break;
00062     }
00063   }
00064 
00065   void
00066   rel(Space* home, SetOpType op, const IntVarArgs& x, SetVar y) {
00067     if (home->failed()) return;
00068     ViewArray<SingletonView> xa(home,x.size());
00069     for (int i=x.size(); i--;) {
00070       Int::IntView iv(x[i]);
00071       SingletonView sv(iv);
00072       xa[i] = sv;
00073     }
00074       
00075     switch(op) {
00076     case SOT_UNION:
00077       GECODE_ES_FAIL(home,(RelOp::UnionN<SingletonView,SetView>
00078                            ::post(home, xa, y)));
00079       break;
00080     case SOT_DUNION:
00081       GECODE_ES_FAIL(home,(RelOp::PartitionN<SingletonView,SetView>
00082                            ::post(home, xa, y)));
00083       break;
00084     case SOT_INTER:
00085       GECODE_ES_FAIL(home,
00086                      (RelOp::IntersectionN<SingletonView,SetView>
00087                       ::post(home, xa, y)));
00088       break;
00089     case SOT_MINUS:
00090       throw InvalidRelation("rel minus");
00091       break;
00092     }
00093   }
00094 }
00095 
00096 // STATISTICS: set-post