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