00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 namespace Gecode {
00023
00024 namespace Int {
00025
00026
00027
00028
00029
00030 forceinline
00031 OffsetView::OffsetView(void) {}
00032 forceinline
00033 OffsetView::OffsetView(const IntView& x, int d)
00034 : DerivedViewBase<IntView>(x), c(d) {}
00035 forceinline void
00036 OffsetView::init(const IntView& x, int d) {
00037 view=x; c=d;
00038 }
00039 forceinline int
00040 OffsetView::offset(void) const {
00041 return c;
00042 }
00043
00044
00045
00046
00047
00048
00049 forceinline int
00050 OffsetView::min(void) const {
00051 return view.min()+c;
00052 }
00053 forceinline int
00054 OffsetView::max(void) const {
00055 return view.max()+c;
00056 }
00057 forceinline int
00058 OffsetView::med(void) const {
00059 return view.med()+c;
00060 }
00061 forceinline int
00062 OffsetView::val(void) const {
00063 return view.val()+c;
00064 }
00065
00066 forceinline unsigned int
00067 OffsetView::width(void) const {
00068 return view.width();
00069 }
00070 forceinline unsigned int
00071 OffsetView::size(void) const {
00072 return view.size();
00073 }
00074 forceinline unsigned int
00075 OffsetView::regret_min(void) const {
00076 return view.regret_min();
00077 }
00078 forceinline unsigned int
00079 OffsetView::regret_max(void) const {
00080 return view.regret_max();
00081 }
00082
00083
00084
00085
00086
00087 forceinline bool
00088 OffsetView::range(void) const {
00089 return view.range();
00090 }
00091 forceinline bool
00092 OffsetView::assigned(void) const {
00093 return view.assigned();
00094 }
00095
00096 forceinline bool
00097 OffsetView::in(int n) const {
00098 return view.in(n-c);
00099 }
00100 forceinline bool
00101 OffsetView::in(double n) const {
00102 return view.in(n-c);
00103 }
00104
00105
00106
00107
00108
00109
00110 forceinline ModEvent
00111 OffsetView::lq(Space* home, int n) {
00112 return view.lq(home,n-c);
00113 }
00114 forceinline ModEvent
00115 OffsetView::lq(Space* home, double n) {
00116 return view.lq(home,n-c);
00117 }
00118 forceinline ModEvent
00119 OffsetView::le(Space* home, int n) {
00120 return view.le(home,n-c);
00121 }
00122 forceinline ModEvent
00123 OffsetView::le(Space* home, double n) {
00124 return view.le(home,n-c);
00125 }
00126 forceinline ModEvent
00127 OffsetView::gq(Space* home, int n) {
00128 return view.gq(home,n-c);
00129 }
00130 forceinline ModEvent
00131 OffsetView::gq(Space* home, double n) {
00132 return view.gq(home,n-c);
00133 }
00134 forceinline ModEvent
00135 OffsetView::gr(Space* home, int n) {
00136 return view.gr(home,n-c);
00137 }
00138 forceinline ModEvent
00139 OffsetView::gr(Space* home, double n) {
00140 return view.gr(home,n-c);
00141 }
00142 forceinline ModEvent
00143 OffsetView::nq(Space* home, int n) {
00144 return view.nq(home,n-c);
00145 }
00146 forceinline ModEvent
00147 OffsetView::nq(Space* home, double n) {
00148 return view.nq(home,n-c);
00149 }
00150 forceinline ModEvent
00151 OffsetView::eq(Space* home, int n) {
00152 return view.eq(home,n-c);
00153 }
00154 forceinline ModEvent
00155 OffsetView::eq(Space* home, double n) {
00156 return view.eq(home,n-c);
00157 }
00158
00159
00160
00161
00162
00163
00164
00165 template <class I>
00166 ModEvent
00167 OffsetView::narrow(Space* home, I& i) {
00168 Iter::Ranges::Offset<I> oi(i,-c); return view.narrow(home,oi);
00169 }
00170 template <class I>
00171 ModEvent
00172 OffsetView::inter(Space* home, I& i) {
00173 Iter::Ranges::Offset<I> oi(i,-c); return view.inter(home,oi);
00174 }
00175 template <class I>
00176 ModEvent
00177 OffsetView::minus(Space* home, I& i) {
00178 Iter::Ranges::Offset<I> oi(i,-c); return view.minus(home,oi);
00179 }
00180
00181
00182
00183
00184
00185
00186
00187 forceinline ModEvent
00188 OffsetView::pme(const Propagator* p) {
00189 return IntView::pme(p);
00190 }
00191 forceinline PropModEvent
00192 OffsetView::pme(ModEvent me) {
00193 return IntView::pme(me);
00194 }
00195
00196
00197
00198
00199
00200
00201 forceinline void
00202 OffsetView::subscribe(Space* home, Propagator* p, PropCond pc,
00203 bool process) {
00204 view.subscribe(home,p,pc,process);
00205 }
00206 forceinline void
00207 OffsetView::cancel(Space* home, Propagator* p, PropCond pc) {
00208 view.cancel(home,p,pc);
00209 }
00210
00211
00212
00213
00214
00215
00216 forceinline void
00217 OffsetView::update(Space* home, bool share, OffsetView& x) {
00218 c=x.c; view.update(home,share,x.view);
00219 }
00220
00221
00226 template <>
00227 class ViewRanges<OffsetView>
00228 : public Iter::Ranges::Offset<ViewRanges<IntView> > {
00229 public:
00231
00232
00233 ViewRanges(void);
00235 ViewRanges(const OffsetView& x);
00237 void init(const OffsetView& x);
00239 };
00240
00241 forceinline
00242 ViewRanges<OffsetView>::ViewRanges(void) {}
00243
00244 forceinline
00245 ViewRanges<OffsetView>::ViewRanges(const OffsetView& x) {
00246 ViewRanges<IntView> xi(x.base());
00247 Iter::Ranges::Offset<ViewRanges<IntView> >::init(xi,x.offset());
00248 }
00249
00250 forceinline void
00251 ViewRanges<OffsetView>::init(const OffsetView& x) {
00252 ViewRanges<IntView> xi(x.base());
00253 Iter::Ranges::Offset<ViewRanges<IntView> >::init(xi,x.offset());
00254 }
00255 }
00256
00257
00258
00259
00260
00261 forceinline bool
00262 same(const Int::OffsetView& x, const Int::OffsetView& y) {
00263 return same(x.base(),y.base()) && (x.offset() == y.offset());
00264 }
00265 forceinline bool
00266 before(const Int::OffsetView& x, const Int::OffsetView& y) {
00267 return before(x.base(),y.base())
00268 || (same(x.base(),y.base()) && (x.offset() < y.offset()));
00269 }
00270
00271 }
00272
00273
00274