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 OffsetView::OffsetView(void) {}
00046 forceinline
00047 OffsetView::OffsetView(const IntView& y, int d)
00048 : DerivedView<IntView>(y), c(d) {}
00049
00050
00051
00052
00053
00054
00055 forceinline int
00056 OffsetView::offset(void) const {
00057 return c;
00058 }
00059 forceinline void
00060 OffsetView::offset(int n) {
00061 c = n;
00062 }
00063 forceinline int
00064 OffsetView::min(void) const {
00065 return x.min()+c;
00066 }
00067 forceinline int
00068 OffsetView::max(void) const {
00069 return x.max()+c;
00070 }
00071 forceinline int
00072 OffsetView::med(void) const {
00073 return x.med()+c;
00074 }
00075 forceinline int
00076 OffsetView::val(void) const {
00077 return x.val()+c;
00078 }
00079 #ifdef GECODE_HAS_CBS
00080 forceinline int
00081 OffsetView::baseval(int val) const {
00082 return val-c;
00083 }
00084 #endif
00085
00086 forceinline unsigned int
00087 OffsetView::width(void) const {
00088 return x.width();
00089 }
00090 forceinline unsigned int
00091 OffsetView::size(void) const {
00092 return x.size();
00093 }
00094 forceinline unsigned int
00095 OffsetView::regret_min(void) const {
00096 return x.regret_min();
00097 }
00098 forceinline unsigned int
00099 OffsetView::regret_max(void) const {
00100 return x.regret_max();
00101 }
00102
00103
00104
00105
00106
00107 forceinline bool
00108 OffsetView::range(void) const {
00109 return x.range();
00110 }
00111 forceinline bool
00112 OffsetView::in(int n) const {
00113 return x.in(n-c);
00114 }
00115 forceinline bool
00116 OffsetView::in(long long int n) const {
00117 return x.in(n-c);
00118 }
00119
00120
00121
00122
00123
00124
00125
00126 forceinline ModEvent
00127 OffsetView::lq(Space& home, int n) {
00128 return x.lq(home,n-c);
00129 }
00130 forceinline ModEvent
00131 OffsetView::lq(Space& home, long long int n) {
00132 return x.lq(home,n-c);
00133 }
00134
00135 forceinline ModEvent
00136 OffsetView::le(Space& home, int n) {
00137 return x.le(home,n-c);
00138 }
00139 forceinline ModEvent
00140 OffsetView::le(Space& home, long long int n) {
00141 return x.le(home,n-c);
00142 }
00143
00144 forceinline ModEvent
00145 OffsetView::gq(Space& home, int n) {
00146 return x.gq(home,n-c);
00147 }
00148 forceinline ModEvent
00149 OffsetView::gq(Space& home, long long int n) {
00150 return x.gq(home,n-c);
00151 }
00152
00153 forceinline ModEvent
00154 OffsetView::gr(Space& home, int n) {
00155 return x.gr(home,n-c);
00156 }
00157 forceinline ModEvent
00158 OffsetView::gr(Space& home, long long int n) {
00159 return x.gr(home,n-c);
00160 }
00161
00162 forceinline ModEvent
00163 OffsetView::nq(Space& home, int n) {
00164 return x.nq(home,n-c);
00165 }
00166 forceinline ModEvent
00167 OffsetView::nq(Space& home, long long int n) {
00168 return x.nq(home,n-c);
00169 }
00170
00171 forceinline ModEvent
00172 OffsetView::eq(Space& home, int n) {
00173 return x.eq(home,n-c);
00174 }
00175 forceinline ModEvent
00176 OffsetView::eq(Space& home, long long int n) {
00177 return x.eq(home,n-c);
00178 }
00179
00180
00181
00182
00183
00184
00185 template<class I>
00186 forceinline ModEvent
00187 OffsetView::narrow_r(Space& home, I& i, bool depend) {
00188 Iter::Ranges::Offset<I> oi(i,-c);
00189 return x.narrow_r(home,oi,depend);
00190 }
00191 template<class I>
00192 forceinline ModEvent
00193 OffsetView::inter_r(Space& home, I& i, bool depend) {
00194 Iter::Ranges::Offset<I> oi(i,-c);
00195 return x.inter_r(home,oi,depend);
00196 }
00197 template<class I>
00198 forceinline ModEvent
00199 OffsetView::minus_r(Space& home, I& i, bool depend) {
00200 Iter::Ranges::Offset<I> oi(i,-c);
00201 return x.minus_r(home,oi,depend);
00202 }
00203 template<class I>
00204 forceinline ModEvent
00205 OffsetView::narrow_v(Space& home, I& i, bool depend) {
00206 Iter::Values::Offset<I> oi(i,-c);
00207 return x.narrow_v(home,oi,depend);
00208 }
00209 template<class I>
00210 forceinline ModEvent
00211 OffsetView::inter_v(Space& home, I& i, bool depend) {
00212 Iter::Values::Offset<I> oi(i,-c);
00213 return x.inter_v(home,oi,depend);
00214 }
00215 template<class I>
00216 forceinline ModEvent
00217 OffsetView::minus_v(Space& home, I& i, bool depend) {
00218 Iter::Values::Offset<I> oi(i,-c);
00219 return x.minus_v(home,oi,depend);
00220 }
00221
00222
00223
00224
00225
00226
00227
00228 forceinline ModEventDelta
00229 OffsetView::med(ModEvent me) {
00230 return IntView::med(me);
00231 }
00232
00233
00234
00235
00236
00237
00238 forceinline int
00239 OffsetView::min(const Delta& d) const {
00240 return x.min(d)+c;
00241 }
00242 forceinline int
00243 OffsetView::max(const Delta& d) const {
00244 return x.max(d)+c;
00245 }
00246 forceinline unsigned int
00247 OffsetView::width(const Delta& d) const {
00248 return x.width(d);
00249 }
00250 forceinline bool
00251 OffsetView::any(const Delta& d) const {
00252 return x.any(d);
00253 }
00254
00255
00256
00257
00258
00259
00260
00261 forceinline void
00262 OffsetView::update(Space& home, OffsetView& y) {
00263 DerivedView<IntView>::update(home,y);
00264 c=y.c;
00265 }
00266
00267
00268
00269
00270
00271
00272 forceinline bool
00273 OffsetView::operator <(const OffsetView& y) const {
00274 return ((base() < y.base())
00275 || ((base() == y.base()) && (offset() < y.offset())));
00276 }
00277
00278
00283 template<>
00284 class ViewRanges<OffsetView>
00285 : public Iter::Ranges::Offset<ViewRanges<IntView> > {
00286 public:
00288
00289
00290 ViewRanges(void);
00292 ViewRanges(const OffsetView& x);
00294 void init(const OffsetView& x);
00296 };
00297
00298 forceinline
00299 ViewRanges<OffsetView>::ViewRanges(void) {}
00300
00301 forceinline
00302 ViewRanges<OffsetView>::ViewRanges(const OffsetView& x) {
00303 ViewRanges<IntView> xi(x.base());
00304 Iter::Ranges::Offset<ViewRanges<IntView> >::init(xi,x.offset());
00305 }
00306
00307 forceinline void
00308 ViewRanges<OffsetView>::init(const OffsetView& x) {
00309 ViewRanges<IntView> xi(x.base());
00310 Iter::Ranges::Offset<ViewRanges<IntView> >::init(xi,x.offset());
00311 }
00312
00313
00314
00315
00316
00317 forceinline bool
00318 operator ==(const OffsetView& x, const OffsetView& y) {
00319 return (x.base() == y.base()) && (x.offset() == y.offset());
00320 }
00321 forceinline bool
00322 operator !=(const OffsetView& x, const OffsetView& y) {
00323 return !(x == y);
00324 }
00325
00326 }}
00327
00328
00329