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) {
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::post_int<IntView,IntView>(home,cs,x0,x1)));
00054 }
00055
00056 void
00057 element(Space& home, const IntArgs& c, IntVar x0, BoolVar x1,
00058 IntConLevel) {
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,(Element::post_int<IntView,BoolView>(home,cs,x0,x1)));
00066 }
00067
00068 void
00069 element(Space& home, const IntArgs& c, IntVar x0, int x1,
00070 IntConLevel) {
00071 Limits::check(x1,"Int::element");
00072 if (home.failed()) return;
00073 Element::IntSharedArray cs(c.size());
00074 for (int i = c.size(); i--; ) {
00075 Limits::check(c[i],"Int::element");
00076 cs[i] = c[i];
00077 }
00078 ConstIntView cx1(x1);
00079 GECODE_ES_FAIL(home,
00080 (Element::post_int<IntView,ConstIntView>(home,cs,x0,cx1)));
00081 }
00082
00083 void
00084 element(Space& home, const IntVarArgs& c, IntVar x0, IntVar x1,
00085 IntConLevel icl) {
00086 if (home.failed()) return;
00087 Element::IdxViewArray<IntView> iv(home,c);
00088 if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00089 GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,IntView>
00090 ::post(home,iv,x0,x1)));
00091 } else {
00092 GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,IntView>
00093 ::post(home,iv,x0,x1)));
00094 }
00095 }
00096
00097 void
00098 element(Space& home, const IntVarArgs& c, IntVar x0, int x1,
00099 IntConLevel icl) {
00100 Limits::check(x1,"Int::element");
00101 if (home.failed()) return;
00102 Element::IdxViewArray<IntView> iv(home,c);
00103 ConstIntView v1(x1);
00104 if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00105 GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,ConstIntView>
00106 ::post(home,iv,x0,v1)));
00107 } else {
00108 GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,ConstIntView>
00109 ::post(home,iv,x0,v1)));
00110 }
00111 }
00112
00113 void
00114 element(Space& home, const BoolVarArgs& c, IntVar x0, BoolVar x1,
00115 IntConLevel) {
00116 if (home.failed()) return;
00117 Element::IdxViewArray<BoolView> iv(home,c);
00118 GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,BoolView>
00119 ::post(home,iv,x0,x1)));
00120 }
00121
00122 void
00123 element(Space& home, const BoolVarArgs& c, IntVar x0, int x1,
00124 IntConLevel) {
00125 Limits::check(x1,"Int::element");
00126 if (home.failed()) return;
00127 Element::IdxViewArray<BoolView> iv(home,c);
00128 ConstIntView v1(x1);
00129 GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,ConstIntView>
00130 ::post(home,iv,x0,v1)));
00131 }
00132
00133 }
00134
00135