this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Guido Tack <tack@gecode.org>
5 *
6 * Copyright:
7 * Guido Tack, 2011
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#include <sstream>
35
36namespace Gecode { namespace Set {
37
38 template<class View>
39 forceinline
40 CachedView<View>::CachedView(void) {}
41
42 template<class View>
43 forceinline
44 CachedView<View>::CachedView(const View& y)
45 : DerivedView<View>(y) {}
46
47 template<class View>
48 forceinline unsigned int
49 CachedView<View>::glbSize(void) const {
50 return x.glbSize();
51 }
52
53 template<class View>
54 forceinline unsigned int
55 CachedView<View>::lubSize(void) const {
56 return x.lubSize();
57 }
58
59 template<class View>
60 forceinline unsigned int
61 CachedView<View>::unknownSize(void) const {
62 return x.unknownSize();
63 }
64
65 template<class View>
66 forceinline bool
67 CachedView<View>::contains(int n) const { return x.contains(n); }
68
69 template<class View>
70 forceinline bool
71 CachedView<View>::notContains(int n) const { return x.notContains(n); }
72
73 template<class View>
74 forceinline unsigned int
75 CachedView<View>::cardMin(void) const {
76 return x.cardMin();
77 }
78
79 template<class View>
80 forceinline unsigned int
81 CachedView<View>::cardMax(void) const {
82 return x.cardMax();
83 }
84
85 template<class View>
86 forceinline int
87 CachedView<View>::lubMin(void) const {
88 return x.lubMin();
89 }
90
91 template<class View>
92 forceinline int
93 CachedView<View>::lubMax(void) const {
94 return x.lubMax();
95 }
96
97 template<class View>
98 forceinline int
99 CachedView<View>::glbMin(void) const {
100 return x.glbMin();
101 }
102
103 template<class View>
104 forceinline int
105 CachedView<View>::glbMax(void) const {
106 return x.glbMax();
107 }
108
109 template<class View>
110 forceinline ModEvent
111 CachedView<View>::cardMin(Space& home, unsigned int m) {
112 return x.cardMin(home,m);
113 }
114
115 template<class View>
116 forceinline ModEvent
117 CachedView<View>::cardMax(Space& home, unsigned int m) {
118 return x.cardMax(home,m);
119 }
120
121 template<class View>
122 forceinline ModEvent
123 CachedView<View>::include(Space& home, int i) {
124 return x.include(home,i);
125 }
126
127 template<class View>
128 forceinline ModEvent
129 CachedView<View>::exclude(Space& home, int i) {
130 return x.exclude(home,i);
131 }
132
133 template<class View>
134 forceinline ModEvent
135 CachedView<View>::intersect(Space& home, int i) {
136 return x.intersect(home,i);
137 }
138
139 template<class View>
140 forceinline ModEvent
141 CachedView<View>::intersect(Space& home, int i, int j) {
142 return x.intersect(home,i,j);
143 }
144
145 template<class View>
146 forceinline ModEvent
147 CachedView<View>::include(Space& home, int i, int j) {
148 return x.include(home,i,j);
149 }
150
151 template<class View>
152 forceinline ModEvent
153 CachedView<View>::exclude(Space& home, int i, int j) {
154 return x.exclude(home,i,j);
155 }
156
157 template<class View>
158 template<class I> ModEvent
159 CachedView<View>::excludeI(Space& home,I& iter) {
160 return x.excludeI(home,iter);
161 }
162
163 template<class View>
164 template<class I> ModEvent
165 CachedView<View>::includeI(Space& home,I& iter) {
166 return x.includeI(home,iter);
167 }
168
169 template<class View>
170 template<class I> ModEvent
171 CachedView<View>::intersectI(Space& home,I& iter) {
172 return x.intersectI(home,iter);
173 }
174
175 template<class View>
176 forceinline void
177 CachedView<View>::subscribe(Space& home, Propagator& p, PropCond pc,
178 bool schedule) {
179 x.subscribe(home,p,pc,schedule);
180 }
181
182 template<class View>
183 forceinline void
184 CachedView<View>::cancel(Space& home, Propagator& p, PropCond pc) {
185 x.cancel(home,p,pc);
186 }
187
188 template<class View>
189 forceinline void
190 CachedView<View>::subscribe(Space& home, Advisor& a) {
191 x.subscribe(home,a);
192 }
193
194 template<class View>
195 forceinline void
196 CachedView<View>::cancel(Space& home, Advisor& a) {
197 x.cancel(home,a);
198 }
199
200 template<class View>
201 forceinline void
202 CachedView<View>::schedule(Space& home, Propagator& p, ModEvent me) {
203 return View::schedule(home,p,me);
204 }
205 template<class View>
206 forceinline ModEvent
207 CachedView<View>::me(const ModEventDelta& med) {
208 return View::me(med);
209 }
210
211 template<class View>
212 forceinline ModEventDelta
213 CachedView<View>::med(ModEvent me) {
214 return View::med(me);
215 }
216
217 /*
218 * Delta information for advisors
219 *
220 */
221
222 template<class View>
223 forceinline ModEvent
224 CachedView<View>::modevent(const Delta& d) {
225 return View::modevent(d);
226 }
227
228 template<class View>
229 forceinline int
230 CachedView<View>::glbMin(const Delta& d) const {
231 return x.glbMin(d);
232 }
233
234 template<class View>
235 forceinline int
236 CachedView<View>::glbMax(const Delta& d) const {
237 return x.glbMax(d);
238 }
239
240 template<class View>
241 forceinline bool
242 CachedView<View>::glbAny(const Delta& d) const {
243 return x.glbAny(d);
244 }
245
246 template<class View>
247 forceinline int
248 CachedView<View>::lubMin(const Delta& d) const {
249 return x.lubMin(d);
250 }
251
252 template<class View>
253 forceinline int
254 CachedView<View>::lubMax(const Delta& d) const {
255 return x.lubMax(d);
256 }
257
258 template<class View>
259 forceinline bool
260 CachedView<View>::lubAny(const Delta& d) const {
261 return x.lubAny(d);
262 }
263
264 template<class View>
265 forceinline void
266 CachedView<View>::update(Space& home, CachedView<View>& y) {
267 lubCache.update(home,y.lubCache);
268 glbCache.update(home,y.glbCache);
269 DerivedView<View>::update(home,y);
270 }
271
272 /*
273 * Cache operations
274 *
275 */
276 template<class View>
277 void
278 CachedView<View>::initCache(Space& home,
279 const IntSet& glb, const IntSet& lub) {
280 glbCache.init(home);
281 IntSetRanges gr(glb);
282 glbCache.includeI(home,gr);
283 lubCache.init(home);
284 IntSetRanges lr(lub);
285 lubCache.intersectI(home,lr);
286 }
287
288 template<class View>
289 forceinline void
290 CachedView<View>::cacheGlb(Space& home) {
291 GlbRanges<View> gr(DerivedView<View>::base());
292 glbCache.includeI(home,gr);
293 }
294
295 template<class View>
296 forceinline void
297 CachedView<View>::cacheLub(Space& home) {
298 LubRanges<View> lr(DerivedView<View>::base());
299 lubCache.intersectI(home,lr);
300 }
301
302 template<class View>
303 forceinline bool
304 CachedView<View>::glbModified(void) const {
305 return glbCache.size() != glbSize();
306 }
307
308 template<class View>
309 forceinline bool
310 CachedView<View>::lubModified(void) const {
311 return lubCache.size() != lubSize();
312 }
313
314 /**
315 * \brief %Range iterator for least upper bound of cached set views
316 * \ingroup TaskActorSetView
317 */
318 template<class View>
319 class LubRanges<CachedView<View> > : public LubRanges<View> {
320 public:
321 /// \name Constructors and initialization
322 //@{
323 /// Default constructor
324 LubRanges(void) {}
325 /// Initialize with ranges for view \a x
326 LubRanges(const CachedView<View>& x);
327 /// Initialize with ranges for view \a x
328 void init(const CachedView<View>& x);
329 //@}
330 };
331
332 template<class View>
333 forceinline
334 LubRanges<CachedView<View> >::LubRanges(const CachedView<View>& s)
335 : LubRanges<View>(s.base()) {}
336
337 template<class View>
338 forceinline void
339 LubRanges<CachedView<View> >::init(const CachedView<View>& s) {
340 LubRanges<View>::init(s.base());
341 }
342
343 /**
344 * \brief %Range iterator for greatest lower bound of cached set views
345 * \ingroup TaskActorSetView
346 */
347 template<class View>
348 class GlbRanges<CachedView<View> > : public GlbRanges<View> {
349 public:
350 /// \name Constructors and initialization
351 //@{
352 /// Default constructor
353 GlbRanges(void) {}
354 /// Initialize with ranges for view \a x
355 GlbRanges(const CachedView<View> & x);
356 /// Initialize with ranges for view \a x
357 void init(const CachedView<View> & x);
358 //@}
359 };
360
361 template<class View>
362 forceinline
363 GlbRanges<CachedView<View> >::GlbRanges(const CachedView<View> & s)
364 : GlbRanges<View>(s.base()) {}
365
366 template<class View>
367 forceinline void
368 GlbRanges<CachedView<View> >::init(const CachedView<View> & s) {
369 GlbRanges<View>::init(s.base());
370 }
371
372 template<class Char, class Traits, class View>
373 std::basic_ostream<Char,Traits>&
374 operator <<(std::basic_ostream<Char,Traits>& os,
375 const CachedView<View>& x) {
376 return os << x.base();
377 }
378
379 template<class View>
380 forceinline bool
381 operator ==(const CachedView<View>& x, const CachedView<View>& y) {
382 return x.base() == y.base();
383 }
384
385 template<class View>
386 forceinline bool
387 operator !=(const CachedView<View>& x, const CachedView<View>& y) {
388 return x.base() != y.base();
389 }
390
391 template<class View>
392 forceinline
393 GlbDiffRanges<View>::GlbDiffRanges(const CachedView<View>& x)
394 : gr(x.base()), cr(x.glbCache) {
395 Iter::Ranges::Diff<GlbRanges<View>,BndSetRanges>::init(gr,cr);
396 }
397
398 template<class View>
399 forceinline
400 LubDiffRanges<View>::LubDiffRanges(const CachedView<View>& x)
401 : cr(x.lubCache), lr(x.base()) {
402 Iter::Ranges::Diff<BndSetRanges,LubRanges<View> >::init(cr,lr);
403 }
404
405}}
406
407// STATISTICS: set-var