spec.hpp
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
00038 namespace Gecode { namespace Int { namespace Dom {
00039
00040 template<class View>
00041 forceinline
00042 ReIntSet<View>::ReIntSet
00043 (Home home, View x, const IntSet& s, BoolView b)
00044 : ReUnaryPropagator<View,PC_INT_DOM,BoolView>(home,x,b), is(s) {
00045 home.notice(*this,AP_DISPOSE);
00046 }
00047
00048 template<class View>
00049 forceinline size_t
00050 ReIntSet<View>::dispose(Space& home) {
00051 home.ignore(*this,AP_DISPOSE);
00052 is.~IntSet();
00053 (void) ReUnaryPropagator<View,PC_INT_DOM,BoolView>::dispose(home);
00054 return sizeof(*this);
00055 }
00056
00057 template<class View>
00058 ExecStatus
00059 ReIntSet<View>::post(Home home, View x, const IntSet& s, BoolView b) {
00060 if (s.ranges() == 0) {
00061 GECODE_ME_CHECK(b.zero(home));
00062 } else if (s.ranges() == 1) {
00063 return ReRange<View>::post(home,x,s.min(),s.max(),b);
00064 } else if (b.one()) {
00065 IntSetRanges i_is(s);
00066 GECODE_ME_CHECK(x.inter_r(home,i_is,false));
00067 } else if (b.zero()) {
00068 IntSetRanges i_is(s);
00069 GECODE_ME_CHECK(x.minus_r(home,i_is,false));
00070 } else {
00071 (void) new (home) ReIntSet<View>(home,x,s,b);
00072 }
00073 return ES_OK;
00074 }
00075
00076
00077 template<class View>
00078 forceinline
00079 ReIntSet<View>::ReIntSet(Space& home, bool share, ReIntSet& p)
00080 : ReUnaryPropagator<View,PC_INT_DOM,BoolView>(home,share,p) {
00081 is.update(home,share,p.is);
00082 }
00083
00084 template<class View>
00085 Actor*
00086 ReIntSet<View>::copy(Space& home, bool share) {
00087 return new (home) ReIntSet(home,share,*this);
00088 }
00089
00090 template<class View>
00091 ExecStatus
00092 ReIntSet<View>::propagate(Space& home, const ModEventDelta&) {
00093 IntSetRanges i_is(is);
00094 if (b.one()) {
00095 GECODE_ME_CHECK(x0.inter_r(home,i_is,false));
00096 return home.ES_SUBSUMED(*this);
00097 }
00098 if (b.zero()) {
00099 GECODE_ME_CHECK(x0.minus_r(home,i_is,false));
00100 return home.ES_SUBSUMED(*this);
00101 }
00102
00103 {
00104 ViewRanges<View> i_x(x0);
00105
00106 switch (Iter::Ranges::compare(i_x,i_is)) {
00107 case Iter::Ranges::CS_SUBSET:
00108 GECODE_ME_CHECK(b.one_none(home));
00109 return home.ES_SUBSUMED(*this);
00110 case Iter::Ranges::CS_DISJOINT:
00111 GECODE_ME_CHECK(b.zero_none(home));
00112 return home.ES_SUBSUMED(*this);
00113 case Iter::Ranges::CS_NONE:
00114 break;
00115 default: GECODE_NEVER;
00116 }
00117 }
00118 return ES_FIX;
00119 }
00120
00121 }}}
00122
00123
00124