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 { namespace Int {
00039
00040
00041
00042
00043
00044 forceinline
00045 ZeroIntView::ZeroIntView(void) {}
00046
00047
00048
00049
00050
00051 forceinline int
00052 ZeroIntView::min(void) const {
00053 return 0;
00054 }
00055 forceinline int
00056 ZeroIntView::max(void) const {
00057 return 0;
00058 }
00059 forceinline int
00060 ZeroIntView::med(void) const {
00061 return 0;
00062 }
00063 forceinline int
00064 ZeroIntView::val(void) const {
00065 return 0;
00066 }
00067
00068 forceinline unsigned int
00069 ZeroIntView::size(void) const {
00070 return 1;
00071 }
00072 forceinline unsigned int
00073 ZeroIntView::width(void) const {
00074 return 1;
00075 }
00076 forceinline unsigned int
00077 ZeroIntView::regret_min(void) const {
00078 return 0;
00079 }
00080 forceinline unsigned int
00081 ZeroIntView::regret_max(void) const {
00082 return 0;
00083 }
00084
00085
00086
00087
00088
00089
00090 forceinline bool
00091 ZeroIntView::range(void) const {
00092 return true;
00093 }
00094 forceinline bool
00095 ZeroIntView::in(int n) const {
00096 return n == 0;
00097 }
00098 forceinline bool
00099 ZeroIntView::in(double n) const {
00100 return n == 0;
00101 }
00102
00103
00104
00105
00106
00107
00108 forceinline ModEvent
00109 ZeroIntView::lq(Space&, int n) {
00110 return (0 <= n) ? ME_INT_NONE : ME_INT_FAILED;
00111 }
00112 forceinline ModEvent
00113 ZeroIntView::lq(Space&, double n) {
00114 return (0 <= n) ? ME_INT_NONE : ME_INT_FAILED;
00115 }
00116
00117 forceinline ModEvent
00118 ZeroIntView::le(Space&, int n) {
00119 return (0 < n) ? ME_INT_NONE : ME_INT_FAILED;
00120 }
00121 forceinline ModEvent
00122 ZeroIntView::le(Space&, double n) {
00123 return (0 < n) ? ME_INT_NONE : ME_INT_FAILED;
00124 }
00125
00126 forceinline ModEvent
00127 ZeroIntView::gq(Space&, int n) {
00128 return (0 >= n) ? ME_INT_NONE : ME_INT_FAILED;
00129 }
00130 forceinline ModEvent
00131 ZeroIntView::gq(Space&, double n) {
00132 return (0 >= n) ? ME_INT_NONE : ME_INT_FAILED;
00133 }
00134
00135 forceinline ModEvent
00136 ZeroIntView::gr(Space&, int n) {
00137 return (0 > n) ? ME_INT_NONE : ME_INT_FAILED;
00138 }
00139 forceinline ModEvent
00140 ZeroIntView::gr(Space&, double n) {
00141 return (0 > n) ? ME_INT_NONE : ME_INT_FAILED;
00142 }
00143
00144 forceinline ModEvent
00145 ZeroIntView::nq(Space&, int n) {
00146 return (0 != n) ? ME_INT_NONE : ME_INT_FAILED;
00147 }
00148 forceinline ModEvent
00149 ZeroIntView::nq(Space&, double n) {
00150 return (0 != n) ? ME_INT_NONE : ME_INT_FAILED;
00151 }
00152
00153 forceinline ModEvent
00154 ZeroIntView::eq(Space&, int n) {
00155 return (0 == n) ? ME_INT_NONE : ME_INT_FAILED;
00156 }
00157 forceinline ModEvent
00158 ZeroIntView::eq(Space&, double n) {
00159 return (0 == n) ? ME_INT_NONE : ME_INT_FAILED;
00160 }
00161
00162
00163
00164
00165
00166
00167
00168 template<class I>
00169 forceinline ModEvent
00170 ZeroIntView::narrow_r(Space&, I& i, bool) {
00171 return i() ? ME_INT_NONE : ME_INT_FAILED;
00172 }
00173 template<class I>
00174 forceinline ModEvent
00175 ZeroIntView::inter_r(Space&, I& i, bool) {
00176 while (i() && (i.max() < 0))
00177 ++i;
00178 return (i() && (i.min() <= 0)) ? ME_INT_NONE : ME_INT_FAILED;
00179 }
00180 template<class I>
00181 forceinline ModEvent
00182 ZeroIntView::minus_r(Space&, I& i, bool) {
00183 while (i() && (i.max() < 0))
00184 ++i;
00185 return (i() && (i.min() <= 0)) ? ME_INT_FAILED : ME_INT_NONE;
00186 }
00187 template<class I>
00188 forceinline ModEvent
00189 ZeroIntView::narrow_v(Space&, I& i, bool) {
00190 return i() ? ME_INT_NONE : ME_INT_FAILED;
00191 }
00192 template<class I>
00193 forceinline ModEvent
00194 ZeroIntView::inter_v(Space&, I& i, bool) {
00195 while (i() && (i.val() < 0))
00196 ++i;
00197 return (i() && (i.val() == 0)) ? ME_INT_NONE : ME_INT_FAILED;
00198 }
00199 template<class I>
00200 forceinline ModEvent
00201 ZeroIntView::minus_v(Space&, I& i, bool) {
00202 while (i() && (i.val() < 0))
00203 ++i;
00204 return (i() && (i.val() == 0)) ? ME_INT_FAILED : ME_INT_NONE;
00205 }
00206
00207
00208
00209
00210
00211 forceinline int
00212 ZeroIntView::min(const Delta&) const {
00213 return 1;
00214 }
00215 forceinline int
00216 ZeroIntView::max(const Delta&) const {
00217 return 0;
00218 }
00219 forceinline bool
00220 ZeroIntView::any(const Delta&) const {
00221 return true;
00222 }
00223
00224
00229 template<>
00230 class ViewRanges<ZeroIntView> {
00231 private:
00233 bool done;
00234 public:
00236
00237
00238 ViewRanges(void);
00240 ViewRanges(const ZeroIntView& x);
00242 void init(const ZeroIntView& x);
00244
00246
00247
00248 bool operator ()(void) const;
00250 void operator ++(void);
00252
00254
00255
00256 int min(void) const;
00258 int max(void) const;
00260 unsigned int width(void) const;
00262 };
00263
00264 forceinline
00265 ViewRanges<ZeroIntView>::ViewRanges(void) {}
00266
00267 forceinline
00268 ViewRanges<ZeroIntView>::ViewRanges(const ZeroIntView&)
00269 : done(false) {}
00270
00271 forceinline bool
00272 ViewRanges<ZeroIntView>::operator ()(void) const {
00273 return !done;
00274 }
00275 forceinline void
00276 ViewRanges<ZeroIntView>::operator ++(void) {
00277 done=true;
00278 }
00279
00280 forceinline int
00281 ViewRanges<ZeroIntView>::min(void) const {
00282 return 0;
00283 }
00284 forceinline int
00285 ViewRanges<ZeroIntView>::max(void) const {
00286 return 0;
00287 }
00288 forceinline unsigned int
00289 ViewRanges<ZeroIntView>::width(void) const {
00290 return 1;
00291 }
00292
00293
00294
00295
00296
00297 forceinline bool
00298 same(const ZeroIntView&, const ZeroIntView&) {
00299 return true;
00300 }
00301
00302 }}
00303
00304
00305