00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "gecode/int/rel.hh"
00023
00024 namespace Gecode { namespace Int { namespace Count {
00025
00026
00027
00028
00029
00030
00031 template <class VX>
00032 ExecStatus
00033 post_eq(Space* home, ViewArray<VX>& x, int y) {
00034 for (int i = x.size(); i--; )
00035 GECODE_ME_CHECK(x[i].eq(home,y));
00036 return ES_SUBSUMED;
00037 }
00038
00039 template <class VX>
00040 ExecStatus
00041 post_nq(Space* home, ViewArray<VX>& x, int y) {
00042 for (int i = x.size(); i--; )
00043 GECODE_ME_CHECK(x[i].nq(home,y));
00044 return ES_SUBSUMED;
00045 }
00046
00047
00048
00049 template <class VX>
00050 ExecStatus
00051 post_eq_bnd(Space* home, ViewArray<VX>& x, VX y) {
00052 ViewArray<VX> z(home,x.size()+1);
00053 z[x.size()] = y;
00054 for (int i = x.size(); i--; )
00055 z[i] = x[i];
00056 GECODE_ES_CHECK(Rel::NaryEqBnd<VX>::post(home,z));
00057 return ES_SUBSUMED;
00058 }
00059
00060 template <class VX>
00061 ExecStatus
00062 post_eq_dom(Space* home, ViewArray<VX>& x, VX y) {
00063 ViewArray<VX> z(home,x.size()+1);
00064 z[x.size()] = y;
00065 for (int i = x.size(); i--; )
00066 z[i] = x[i];
00067 GECODE_ES_CHECK(Rel::NaryEqDom<VX>::post(home,z));
00068 return ES_SUBSUMED;
00069 }
00070
00071 template <class VX>
00072 ExecStatus
00073 post_nq(Space* home, ViewArray<VX>& x, VX y) {
00074 for (int i = x.size(); i--; )
00075 GECODE_ES_CHECK(Rel::Nq<VX>::post(home,x[i],y));
00076 return ES_SUBSUMED;
00077 }
00078
00079
00080
00081
00082
00083
00084 template <class VX>
00085 forceinline PropCond
00086 RelEqDom<VX>::cond(void) const {
00087 return PC_INT_DOM;
00088 }
00089 template <class VX>
00090 forceinline RelTest
00091 RelEqDom<VX>::holds(VX x, ConstIntView y) {
00092 return rtest_eq_dom(x,y.val());
00093 }
00094 template <class VX>
00095 forceinline RelTest
00096 RelEqDom<VX>::holds(VX x, VX y) {
00097 return rtest_eq_dom(x,y);
00098 }
00099 template <class VX>
00100 forceinline ExecStatus
00101 RelEqDom<VX>::post_true(Space* home, ViewArray<VX>& x, ConstIntView y) {
00102 return post_eq(home,x,y.val());
00103 }
00104 template <class VX>
00105 forceinline ExecStatus
00106 RelEqDom<VX>::post_false(Space* home, ViewArray<VX>& x, ConstIntView y) {
00107 return post_nq(home,x,y.val());
00108 }
00109 template <class VX>
00110 forceinline ExecStatus
00111 RelEqDom<VX>::post_true(Space* home, ViewArray<VX>& x, VX y) {
00112 return post_eq_dom(home,x,y);
00113 }
00114 template <class VX>
00115 forceinline ExecStatus
00116 RelEqDom<VX>::post_false(Space* home, ViewArray<VX>& x, VX y) {
00117 return post_nq(home,x,y);
00118 }
00119
00120
00121
00122
00123
00124
00125
00126 template <class VX>
00127 forceinline PropCond
00128 RelEqBnd<VX>::cond(void) const {
00129 return PC_INT_BND;
00130 }
00131 template <class VX>
00132 forceinline RelTest
00133 RelEqBnd<VX>::holds(VX x, ConstIntView y) {
00134 return rtest_eq_bnd(x,y.val());
00135 }
00136 template <class VX>
00137 forceinline RelTest
00138 RelEqBnd<VX>::holds(VX x, VX y) {
00139 return rtest_eq_bnd(x,y);
00140 }
00141 template <class VX>
00142 forceinline ExecStatus
00143 RelEqBnd<VX>::post_true(Space* home, ViewArray<VX>& x, ConstIntView y) {
00144 return post_eq(home,x,y.val());
00145 }
00146 template <class VX>
00147 forceinline ExecStatus
00148 RelEqBnd<VX>::post_false(Space* home, ViewArray<VX>& x, ConstIntView y) {
00149 return post_nq(home,x,y.val());
00150 }
00151 template <class VX>
00152 forceinline ExecStatus
00153 RelEqBnd<VX>::post_true(Space* home, ViewArray<VX>& x, VX y) {
00154 return post_eq_bnd(home,x,y);
00155 }
00156 template <class VX>
00157 forceinline ExecStatus
00158 RelEqBnd<VX>::post_false(Space* home, ViewArray<VX>& x, VX y) {
00159 return post_nq(home,x,y);
00160 }
00161
00162
00163
00164
00165 }}}
00166
00167
00168