rel-op-singleton.cpp
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
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <gecode/set/rel-op.hh>
00038
00039 namespace Gecode {
00040 using namespace Gecode::Set;
00041 using namespace Gecode::Set::Rel;
00042 using namespace Gecode::Set::RelOp;
00043
00044 void
00045 rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y) {
00046 GECODE_POST;
00047 ViewArray<SingletonView> xa(home,x.size());
00048 for (int i=x.size(); i--;) {
00049 Int::IntView iv(x[i]);
00050 SingletonView sv(iv);
00051 xa[i] = sv;
00052 }
00053
00054 switch (op) {
00055 case SOT_UNION:
00056 GECODE_ES_FAIL((RelOp::UnionN<SingletonView,SetView>
00057 ::post(home, xa, y)));
00058 break;
00059 case SOT_DUNION:
00060 GECODE_ES_FAIL((RelOp::PartitionN<SingletonView,SetView>
00061 ::post(home, xa, y)));
00062 break;
00063 case SOT_INTER:
00064 GECODE_ES_FAIL(
00065 (RelOp::IntersectionN<SingletonView,SetView>
00066 ::post(home, xa, y)));
00067 break;
00068 case SOT_MINUS:
00069 throw IllegalOperation("Set::rel");
00070 break;
00071 default:
00072 throw UnknownOperation("Set::rel");
00073 }
00074 }
00075
00076 void
00077 rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z,
00078 SetVar y) {
00079 GECODE_POST;
00080 Set::Limits::check(z, "Set::rel");
00081 ViewArray<SingletonView> xa(home,x.size());
00082 for (int i=x.size(); i--;) {
00083 Int::IntView iv(x[i]);
00084 SingletonView sv(iv);
00085 xa[i] = sv;
00086 }
00087
00088 switch (op) {
00089 case SOT_UNION:
00090 GECODE_ES_FAIL((RelOp::UnionN<SingletonView,SetView>
00091 ::post(home, xa, z, y)));
00092 break;
00093 case SOT_DUNION:
00094 GECODE_ES_FAIL((RelOp::PartitionN<SingletonView,SetView>
00095 ::post(home, xa, z, y)));
00096 break;
00097 case SOT_INTER:
00098 GECODE_ES_FAIL(
00099 (RelOp::IntersectionN<SingletonView,SetView>
00100 ::post(home, xa, z, y)));
00101 break;
00102 case SOT_MINUS:
00103 throw IllegalOperation("set::rel");
00104 break;
00105 default:
00106 throw UnknownOperation("Set::rel");
00107 }
00108 }
00109 }
00110
00111