Generated on Fri Aug 31 2012 16:21:32 for Gecode by doxygen 1.8.1.2
cached.hpp
Go to the documentation of this file.
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  * Last modified:
10  * $Date: 2011-07-14 05:27:53 +1000 (Thu, 14 Jul 2011) $ by $Author: tack $
11  * $Revision: 12201 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include <sstream>
39 
40 namespace Gecode { namespace Set {
41 
42  template<class View>
45 
46  template<class View>
48  CachedView<View>::CachedView(const View& y)
49  : DerivedView<View>(y) {}
50 
51  template<class View>
52  forceinline unsigned int
54  return x.glbSize();
55  }
56 
57  template<class View>
58  forceinline unsigned int
60  return x.lubSize();
61  }
62 
63  template<class View>
64  forceinline unsigned int
66  return x.unknownSize();
67  }
68 
69  template<class View>
70  forceinline bool
71  CachedView<View>::contains(int n) const { return x.contains(n); }
72 
73  template<class View>
74  forceinline bool
75  CachedView<View>::notContains(int n) const { return x.notContains(n); }
76 
77  template<class View>
78  forceinline unsigned int
79  CachedView<View>::cardMin(void) const {
80  return x.cardMin();
81  }
82 
83  template<class View>
84  forceinline unsigned int
85  CachedView<View>::cardMax(void) const {
86  return x.cardMax();
87  }
88 
89  template<class View>
90  forceinline int
91  CachedView<View>::lubMin(void) const {
92  return x.lubMin();
93  }
94 
95  template<class View>
96  forceinline int
97  CachedView<View>::lubMax(void) const {
98  return x.lubMax();
99  }
100 
101  template<class View>
102  forceinline int
103  CachedView<View>::glbMin(void) const {
104  return x.glbMin();
105  }
106 
107  template<class View>
108  forceinline int
109  CachedView<View>::glbMax(void) const {
110  return x.glbMax();
111  }
112 
113  template<class View>
115  CachedView<View>::cardMin(Space& home, unsigned int m) {
116  return x.cardMin(home,m);
117  }
118 
119  template<class View>
121  CachedView<View>::cardMax(Space& home, unsigned int m) {
122  return x.cardMax(home,m);
123  }
124 
125  template<class View>
128  return x.include(home,i);
129  }
130 
131  template<class View>
134  return x.exclude(home,i);
135  }
136 
137  template<class View>
140  return x.intersect(home,i);
141  }
142 
143  template<class View>
145  CachedView<View>::intersect(Space& home, int i, int j) {
146  return x.intersect(home,i,j);
147  }
148 
149  template<class View>
151  CachedView<View>::include(Space& home, int i, int j) {
152  return x.include(home,i,j);
153  }
154 
155  template<class View>
157  CachedView<View>::exclude(Space& home, int i, int j) {
158  return x.exclude(home,i,j);
159  }
160 
161  template<class View>
162  template<class I> ModEvent
164  return x.excludeI(home,iter);
165  }
166 
167  template<class View>
168  template<class I> ModEvent
170  return x.includeI(home,iter);
171  }
172 
173  template<class View>
174  template<class I> ModEvent
176  return x.intersectI(home,iter);
177  }
178 
179  template<class View>
180  forceinline void
182  bool schedule) {
183  x.subscribe(home,p,pc,schedule);
184  }
185 
186  template<class View>
187  forceinline void
189  x.cancel(home,p,pc);
190  }
191 
192  template<class View>
193  forceinline void
195  x.subscribe(home,a);
196  }
197 
198  template<class View>
199  forceinline void
201  x.cancel(home,a);
202  }
203 
204  template<class View>
205  forceinline void
207  return View::schedule(home,p,me);
208  }
209  template<class View>
212  return View::me(med);
213  }
214 
215  template<class View>
218  return View::med(me);
219  }
220 
221  /*
222  * Delta information for advisors
223  *
224  */
225 
226  template<class View>
229  return View::modevent(d);
230  }
231 
232  template<class View>
233  forceinline int
234  CachedView<View>::glbMin(const Delta& d) const {
235  return x.glbMin(d);
236  }
237 
238  template<class View>
239  forceinline int
240  CachedView<View>::glbMax(const Delta& d) const {
241  return x.glbMax(d);
242  }
243 
244  template<class View>
245  forceinline bool
246  CachedView<View>::glbAny(const Delta& d) const {
247  return x.glbAny(d);
248  }
249 
250  template<class View>
251  forceinline int
252  CachedView<View>::lubMin(const Delta& d) const {
253  return x.lubMin(d);
254  }
255 
256  template<class View>
257  forceinline int
258  CachedView<View>::lubMax(const Delta& d) const {
259  return x.lubMax(d);
260  }
261 
262  template<class View>
263  forceinline bool
264  CachedView<View>::lubAny(const Delta& d) const {
265  return x.lubAny(d);
266  }
267 
268  template<class View>
269  forceinline void
270  CachedView<View>::update(Space& home, bool share, CachedView<View>& y) {
271  lubCache.update(home,y.lubCache);
272  glbCache.update(home,y.glbCache);
273  DerivedView<View>::update(home,share,y);
274  }
275 
276  /*
277  * Cache operations
278  *
279  */
280  template<class View>
281  void
283  const IntSet& glb, const IntSet& lub) {
284  glbCache.init(home);
285  IntSetRanges gr(glb);
286  glbCache.includeI(home,gr);
287  lubCache.init(home);
288  IntSetRanges lr(lub);
289  lubCache.intersectI(home,lr);
290  }
291 
292  template<class View>
293  forceinline void
296  glbCache.includeI(home,gr);
297  }
298 
299  template<class View>
300  forceinline void
303  lubCache.intersectI(home,lr);
304  }
305 
306  template<class View>
307  forceinline bool
309  return glbCache.size() != glbSize();
310  }
311 
312  template<class View>
313  forceinline bool
315  return lubCache.size() != lubSize();
316  }
317 
322  template<class View>
323  class LubRanges<CachedView<View> > : public LubRanges<View> {
324  public:
326 
327 
328  LubRanges(void) {}
330  LubRanges(const CachedView<View>& x);
332  void init(const CachedView<View>& x);
334  };
335 
336  template<class View>
339  : LubRanges<View>(s.base()) {}
340 
341  template<class View>
342  forceinline void
345  }
346 
351  template<class View>
352  class GlbRanges<CachedView<View> > : public GlbRanges<View> {
353  public:
355 
356 
357  GlbRanges(void) {}
359  GlbRanges(const CachedView<View> & x);
361  void init(const CachedView<View> & x);
363  };
364 
365  template<class View>
368  : GlbRanges<View>(s.base()) {}
369 
370  template<class View>
371  forceinline void
374  }
375 
376  template<class Char, class Traits, class View>
377  std::basic_ostream<Char,Traits>&
378  operator <<(std::basic_ostream<Char,Traits>& os,
379  const CachedView<View>& x) {
380  return os << x.base();
381  }
382 
383  template<class View>
386  : gr(x.base()), cr(x.glbCache) {
388  }
389 
390  template<class View>
393  : cr(x.lubCache), lr(x.base()) {
395  }
396 
397 }}
398 
399 // STATISTICS: set-var