zero.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 {
00039
00040 namespace Int {
00041
00042
00043
00044
00045
00046 forceinline
00047 ZeroIntView::ZeroIntView(void) {}
00048 forceinline void
00049 ZeroIntView::init(void) {}
00050
00051
00052
00053
00054
00055
00056 forceinline int
00057 ZeroIntView::min(void) const {
00058 return 0;
00059 }
00060 forceinline int
00061 ZeroIntView::max(void) const {
00062 return 0;
00063 }
00064 forceinline int
00065 ZeroIntView::med(void) const {
00066 return 0;
00067 }
00068 forceinline int
00069 ZeroIntView::val(void) const {
00070 return 0;
00071 }
00072
00073 forceinline unsigned int
00074 ZeroIntView::size(void) const {
00075 return 1;
00076 }
00077 forceinline unsigned int
00078 ZeroIntView::width(void) const {
00079 return 1;
00080 }
00081 forceinline unsigned int
00082 ZeroIntView::regret_min(void) const {
00083 return 0;
00084 }
00085 forceinline unsigned int
00086 ZeroIntView::regret_max(void) const {
00087 return 0;
00088 }
00089
00090
00091
00092
00093
00094
00095 forceinline bool
00096 ZeroIntView::range(void) const {
00097 return true;
00098 }
00099 forceinline bool
00100 ZeroIntView::assigned(void) const {
00101 return true;
00102 }
00103
00104 forceinline bool
00105 ZeroIntView::in(int n) const {
00106 return n == 0;
00107 }
00108 forceinline bool
00109 ZeroIntView::in(double n) const {
00110 return n == 0;
00111 }
00112
00113
00114
00115
00116
00117
00118 forceinline ModEvent
00119 ZeroIntView::lq(Space&, int n) {
00120 return (0 <= n) ? ME_INT_NONE : ME_INT_FAILED;
00121 }
00122 forceinline ModEvent
00123 ZeroIntView::lq(Space&, double n) {
00124 return (0 <= n) ? ME_INT_NONE : ME_INT_FAILED;
00125 }
00126
00127 forceinline ModEvent
00128 ZeroIntView::le(Space&, int n) {
00129 return (0 < n) ? ME_INT_NONE : ME_INT_FAILED;
00130 }
00131 forceinline ModEvent
00132 ZeroIntView::le(Space&, double n) {
00133 return (0 < n) ? ME_INT_NONE : ME_INT_FAILED;
00134 }
00135
00136 forceinline ModEvent
00137 ZeroIntView::gq(Space&, int n) {
00138 return (0 >= n) ? ME_INT_NONE : ME_INT_FAILED;
00139 }
00140 forceinline ModEvent
00141 ZeroIntView::gq(Space&, double n) {
00142 return (0 >= n) ? ME_INT_NONE : ME_INT_FAILED;
00143 }
00144
00145 forceinline ModEvent
00146 ZeroIntView::gr(Space&, int n) {
00147 return (0 > n) ? ME_INT_NONE : ME_INT_FAILED;
00148 }
00149 forceinline ModEvent
00150 ZeroIntView::gr(Space&, double n) {
00151 return (0 > n) ? ME_INT_NONE : ME_INT_FAILED;
00152 }
00153
00154 forceinline ModEvent
00155 ZeroIntView::nq(Space&, int n) {
00156 return (0 != n) ? ME_INT_NONE : ME_INT_FAILED;
00157 }
00158 forceinline ModEvent
00159 ZeroIntView::nq(Space&, double n) {
00160 return (0 != n) ? ME_INT_NONE : ME_INT_FAILED;
00161 }
00162
00163 forceinline ModEvent
00164 ZeroIntView::eq(Space&, int n) {
00165 return (0 == n) ? ME_INT_NONE : ME_INT_FAILED;
00166 }
00167 forceinline ModEvent
00168 ZeroIntView::eq(Space&, double n) {
00169 return (0 == n) ? ME_INT_NONE : ME_INT_FAILED;
00170 }
00171
00172
00173
00174
00175
00176
00177
00178 template<class I>
00179 forceinline ModEvent
00180 ZeroIntView::narrow_r(Space& home, I& i, bool) {
00181 Iter::Ranges::IsRangeIter<I>();
00182 return i() ? ME_INT_NONE : ME_INT_FAILED;
00183 }
00184 template<class I>
00185 forceinline ModEvent
00186 ZeroIntView::inter_r(Space& home, I& i, bool) {
00187 Iter::Ranges::IsRangeIter<I>();
00188 while (i() && (i.max() < 0))
00189 ++i;
00190 return (i() && (i.min() <= 0)) ? ME_INT_NONE : ME_INT_FAILED;
00191 }
00192 template<class I>
00193 forceinline ModEvent
00194 ZeroIntView::minus_r(Space& home, I& i, bool) {
00195 Iter::Ranges::IsRangeIter<I>();
00196 while (i() && (i.max() < 0))
00197 ++i;
00198 return (i() && (i.min() <= 0)) ? ME_INT_FAILED : ME_INT_NONE;
00199 }
00200 template<class I>
00201 forceinline ModEvent
00202 ZeroIntView::narrow_v(Space& home, I& i, bool) {
00203 Iter::Values::IsValueIter<I>();
00204 return i() ? ME_INT_NONE : ME_INT_FAILED;
00205 }
00206 template<class I>
00207 forceinline ModEvent
00208 ZeroIntView::inter_v(Space& home, I& i, bool) {
00209 Iter::Values::IsValueIter<I>();
00210 while (i() && (i.val() < 0))
00211 ++i;
00212 return (i() && (i.val() == 0)) ? ME_INT_NONE : ME_INT_FAILED;
00213 }
00214 template<class I>
00215 forceinline ModEvent
00216 ZeroIntView::minus_v(Space& home, I& i, bool) {
00217 Iter::Values::IsValueIter<I>();
00218 while (i() && (i.val() < 0))
00219 ++i;
00220 return (i() && (i.val() == 0)) ? ME_INT_FAILED : ME_INT_NONE;
00221 }
00222
00223
00224
00225
00226
00227
00228 forceinline void
00229 ZeroIntView::schedule(Space& home, Propagator& p, ModEvent me) {
00230 return IntView::schedule(home,p,me);
00231 }
00232 forceinline ModEvent
00233 ZeroIntView::me(const ModEventDelta&) {
00234 return ME_INT_NONE;
00235 }
00236 forceinline ModEventDelta
00237 ZeroIntView::med(ModEvent me) {
00238 return static_cast<ModEventDelta>(me);
00239 }
00240
00241
00242
00243
00244
00245
00246 forceinline void
00247 ZeroIntView::subscribe(Space& home, Propagator& p, PropCond,bool) {
00248 schedule(home,p,ME_INT_VAL);
00249 }
00250 forceinline void
00251 ZeroIntView::cancel(Space&,Propagator&,PropCond) {}
00252 forceinline void
00253 ZeroIntView::subscribe(Space&, Advisor&) {}
00254 forceinline void
00255 ZeroIntView::cancel(Space&,Advisor&) {}
00256
00257
00258
00259
00260
00261
00262
00263 forceinline ModEvent
00264 ZeroIntView::modevent(const Delta&) {
00265 return ME_INT_NONE;
00266 }
00267 forceinline int
00268 ZeroIntView::min(const Delta&) const {
00269 return 1;
00270 }
00271 forceinline int
00272 ZeroIntView::max(const Delta&) const {
00273 return 0;
00274 }
00275 forceinline bool
00276 ZeroIntView::any(const Delta&) const {
00277 return true;
00278 }
00279
00280
00281
00282
00283
00284
00285
00286 forceinline void
00287 ZeroIntView::update(Space&, bool, ZeroIntView&) {}
00288
00289
00294 template<>
00295 class ViewRanges<ZeroIntView> {
00296 private:
00298 bool done;
00299 public:
00301
00302
00303 ViewRanges(void);
00305 ViewRanges(const ZeroIntView& x);
00307 void init(const ZeroIntView& x);
00309
00311
00312
00313 bool operator ()(void) const;
00315 void operator ++(void);
00317
00319
00320
00321 int min(void) const;
00323 int max(void) const;
00325 unsigned int width(void) const;
00327 };
00328
00329 forceinline
00330 ViewRanges<ZeroIntView>::ViewRanges(void) {}
00331
00332 forceinline
00333 ViewRanges<ZeroIntView>::ViewRanges(const ZeroIntView&)
00334 : done(false) {}
00335
00336 forceinline bool
00337 ViewRanges<ZeroIntView>::operator ()(void) const {
00338 return !done;
00339 }
00340 forceinline void
00341 ViewRanges<ZeroIntView>::operator ++(void) {
00342 done=true;
00343 }
00344
00345 forceinline int
00346 ViewRanges<ZeroIntView>::min(void) const {
00347 return 0;
00348 }
00349 forceinline int
00350 ViewRanges<ZeroIntView>::max(void) const {
00351 return 0;
00352 }
00353 forceinline unsigned int
00354 ViewRanges<ZeroIntView>::width(void) const {
00355 return 1;
00356 }
00357
00358 }
00359
00360
00361
00362
00363
00364 forceinline bool
00365 same(const Int::ZeroIntView&, const Int::ZeroIntView&) {
00366 return true;
00367 }
00368 forceinline bool
00369 before(const Int::ZeroIntView&, const Int::ZeroIntView&) {
00370 return false;
00371 }
00372
00373 }
00374
00375
00376