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/rel.hh"
00039
00040 namespace Gecode { namespace Int { namespace Count {
00041
00042
00043
00044
00045
00046
00047 template <class VX>
00048 forceinline RelTest
00049 holds(VX x, ConstIntView y) {
00050 return rtest_eq_dom(x,y.val());
00051 }
00052 template <class VX>
00053 forceinline RelTest
00054 holds(VX x, ZeroIntView) {
00055 return rtest_eq_dom(x,0);
00056 }
00057 template <class VX>
00058 forceinline RelTest
00059 holds(VX x, VX y) {
00060 return rtest_eq_dom(x,y);
00061 }
00062 template <class VX>
00063 forceinline bool
00064 post_true(Space* home, VX x, ConstIntView y) {
00065 return me_failed(x.eq(home,y.val()));
00066 }
00067 template <class VX>
00068 forceinline bool
00069 post_true(Space* home, VX x, ZeroIntView) {
00070 return me_failed(x.eq(home,0));
00071 }
00072 template <class VX>
00073 forceinline bool
00074 post_true(Space* home, ViewArray<VX>& x, ConstIntView y) {
00075 for (int i = x.size(); i--; )
00076 if (me_failed(x[i].eq(home,y.val())))
00077 return true;
00078 return false;
00079 }
00080 template <class VX>
00081 forceinline bool
00082 post_true(Space* home, ViewArray<VX>& x, ZeroIntView) {
00083 for (int i = x.size(); i--; )
00084 if (me_failed(x[i].eq(home,0)))
00085 return true;
00086 return false;
00087 }
00088 template <class VX>
00089 forceinline bool
00090 post_false(Space* home, VX x, ConstIntView y) {
00091 return me_failed(x.nq(home,y.val()));
00092 }
00093 template <class VX>
00094 forceinline bool
00095 post_false(Space* home, VX x, ZeroIntView) {
00096 return me_failed(x.nq(home,0));
00097 }
00098 template <class VX>
00099 forceinline bool
00100 post_false(Space* home, ViewArray<VX>& x, ConstIntView y) {
00101 for (int i = x.size(); i--; )
00102 if (me_failed(x[i].nq(home,y.val())))
00103 return true;
00104 return false;;
00105 }
00106 template <class VX>
00107 forceinline bool
00108 post_false(Space* home, ViewArray<VX>& x, ZeroIntView) {
00109 for (int i = x.size(); i--; )
00110 if (me_failed(x[i].nq(home,0)))
00111 return true;
00112 return false;;
00113 }
00114 template <class VX>
00115 forceinline bool
00116 post_true(Space* home, ViewArray<VX>& x, VX y) {
00117 ViewArray<VX> z(home,x.size()+1);
00118 z[x.size()] = y;
00119 for (int i = x.size(); i--; )
00120 z[i] = x[i];
00121 return Rel::NaryEqDom<VX>::post(home,z) == ES_FAILED;
00122 }
00123 template <class VX>
00124 forceinline bool
00125 post_true(Space* home, VX x, VX y) {
00126 return Rel::EqDom<VX,VX>::post(home,x,y) == ES_FAILED;
00127 }
00128 template <class VX>
00129 forceinline bool
00130 post_false(Space* home, ViewArray<VX>& x, VX y) {
00131 for (int i = x.size(); i--; )
00132 if (Rel::Nq<VX>::post(home,x[i],y) == ES_FAILED)
00133 return true;
00134 return false;
00135 }
00136 template <class VX>
00137 forceinline bool
00138 post_false(Space* home, VX x, VX y) {
00139 return Rel::Nq<VX>::post(home,x,y) == ES_FAILED;
00140 }
00141
00142 }}}
00143
00144