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
00038 #include "gecode/int/element.hh"
00039
00040 namespace Gecode {
00041
00042 using namespace Int;
00043
00044 void
00045 element(Space* home, const IntArgs& c, IntVar x0, IntVar x1,
00046 IntConLevel, PropKind) {
00047 if (home->failed()) return;
00048 Element::IntSharedArray cs(c.size());
00049 for (int i = c.size(); i--; ) {
00050 Limits::check(c[i],"Int::element");
00051 cs[i] = c[i];
00052 }
00053 GECODE_ES_FAIL(home,(Element::Int<IntView,IntView>::post(home,cs,x0,x1)));
00054 }
00055
00056 void
00057 element(Space* home, const IntArgs& c, IntVar x0, BoolVar x1,
00058 IntConLevel, PropKind) {
00059 if (home->failed()) return;
00060 Element::IntSharedArray cs(c.size());
00061 for (int i = c.size(); i--; ) {
00062 Limits::check(c[i],"Int::element");
00063 cs[i] = c[i];
00064 }
00065 GECODE_ES_FAIL(home,
00066 (Element::Int<IntView,BoolView>::post(home,cs,x0,x1)));
00067 }
00068
00069 void
00070 element(Space* home, const IntArgs& c, IntVar x0, int x1,
00071 IntConLevel, PropKind) {
00072 Limits::check(x1,"Int::element");
00073 if (home->failed()) return;
00074 Element::IntSharedArray cs(c.size());
00075 for (int i = c.size(); i--; ) {
00076 Limits::check(c[i],"Int::element");
00077 cs[i] = c[i];
00078 }
00079 ConstIntView cx1(x1);
00080 GECODE_ES_FAIL(home,(Element::Int<IntView,ConstIntView>
00081 ::post(home,cs,x0,cx1)));
00082 }
00083
00084 void
00085 element(Space* home, const IntVarArgs& c, IntVar x0, IntVar x1,
00086 IntConLevel icl, PropKind) {
00087 if (home->failed()) return;
00088 Element::IdxView<IntView>* iv =
00089 Element::IdxView<IntView>::init(home,c);
00090 if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00091 GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,IntView>
00092 ::post(home,iv,c.size(),x0,x1)));
00093 } else {
00094 GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,IntView>
00095 ::post(home,iv,c.size(),x0,x1)));
00096 }
00097 }
00098
00099 void
00100 element(Space* home, const IntVarArgs& c, IntVar x0, int x1,
00101 IntConLevel icl, PropKind) {
00102 Limits::check(x1,"Int::element");
00103 if (home->failed()) return;
00104 Element::IdxView<IntView>* iv =
00105 Element::IdxView<IntView>::init(home,c);
00106 ConstIntView v1(x1);
00107 if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00108 GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,ConstIntView>
00109 ::post(home,iv,c.size(),x0,v1)));
00110 } else {
00111 GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,ConstIntView>
00112 ::post(home,iv,c.size(),x0,v1)));
00113 }
00114 }
00115
00116 void
00117 element(Space* home, const BoolVarArgs& c, IntVar x0, BoolVar x1,
00118 IntConLevel, PropKind) {
00119 if (home->failed()) return;
00120 Element::IdxView<BoolView>* iv =
00121 Element::IdxView<BoolView>::init(home,c);
00122 GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,BoolView>
00123 ::post(home,iv,c.size(),x0,x1)));
00124 }
00125
00126 void
00127 element(Space* home, const BoolVarArgs& c, IntVar x0, int x1,
00128 IntConLevel, PropKind) {
00129 Limits::check(x1,"Int::element");
00130 if (home->failed()) return;
00131 Element::IdxView<BoolView>* iv =
00132 Element::IdxView<BoolView>::init(home,c);
00133 ConstIntView v1(x1);
00134 GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,ConstIntView>
00135 ::post(home,iv,c.size(),x0,v1)));
00136 }
00137
00138 namespace {
00139 using namespace Int;
00140 GECODE_REGISTER2(Element::Int<IntView,ConstIntView>);
00141 GECODE_REGISTER2(Element::Int<IntView,BoolView>);
00142 GECODE_REGISTER2(Element::Int<IntView,IntView>);
00143
00144 GECODE_REGISTER3(Element::ViewBnd<IntView,IntView,ConstIntView>);
00145 GECODE_REGISTER3(Element::ViewBnd<IntView,IntView,IntView>);
00146 GECODE_REGISTER3(Element::ViewBnd<BoolView,IntView,ConstIntView>);
00147 GECODE_REGISTER3(Element::ViewBnd<BoolView,IntView,BoolView>);
00148
00149 GECODE_REGISTER3(Element::ViewDom<IntView,IntView,ConstIntView>);
00150 GECODE_REGISTER3(Element::ViewDom<IntView,IntView,IntView>);
00151 }
00152
00153 }
00154
00155
00156