Generated on Sat Nov 9 2013 19:18:28 for Gecode by doxygen 1.8.4
set.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  * Christian Schulte <schulte@gecode.org>
6  * Gabor Szokoli <szokoli@gecode.org>
7  *
8  * Copyright:
9  * Guido Tack, 2004
10  * Christian Schulte, 2004
11  * Gabor Szokoli, 2004
12  *
13  * Last modified:
14  * $Date: 2010-08-31 16:19:34 +0200 (Tue, 31 Aug 2010) $ by $Author: schulte $
15  * $Revision: 11366 $
16  *
17  * This file is part of Gecode, the generic constraint
18  * development environment:
19  * http://www.gecode.org
20  *
21  * Permission is hereby granted, free of charge, to any person obtaining
22  * a copy of this software and associated documentation files (the
23  * "Software"), to deal in the Software without restriction, including
24  * without limitation the rights to use, copy, modify, merge, publish,
25  * distribute, sublicense, and/or sell copies of the Software, and to
26  * permit persons to whom the Software is furnished to do so, subject to
27  * the following conditions:
28  *
29  * The above copyright notice and this permission notice shall be
30  * included in all copies or substantial portions of the Software.
31  *
32  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39  *
40  */
41 
42 namespace Gecode {
43 
44  /*
45  * Constructors and access
46  *
47  */
48 
50  SetVar::SetVar(void) {}
51 
54  : VarImpVar<Set::SetVarImp>(y.varimp()) {}
55 
58  : VarImpVar<Set::SetVarImp>(y.varimp()) {}
59 
60 
61  /*
62  * Variable information
63  *
64  */
65 
66  forceinline unsigned int
67  SetVar::glbSize(void) const { return x->glbSize(); }
68 
69  forceinline unsigned int
70  SetVar::lubSize(void) const { return x->lubSize(); }
71 
72  forceinline unsigned int
73  SetVar::unknownSize(void) const { return x->lubSize()-x->glbSize(); }
74 
75  forceinline bool
76  SetVar::contains(int i) const { return x->knownIn(i); }
77 
78  forceinline bool
79  SetVar::notContains(int i) const { return x->knownOut(i); }
80 
81  forceinline unsigned int
82  SetVar::cardMin(void) const { return x->cardMin(); }
83 
84  forceinline unsigned int
85  SetVar::cardMax(void) const { return x->cardMax(); }
86 
87  forceinline int
88  SetVar::lubMin(void) const { return x->lubMin(); }
89 
90  forceinline int
91  SetVar::lubMax(void) const { return x->lubMax(); }
92 
93  forceinline int
94  SetVar::glbMin(void) const { return x->glbMin(); }
95 
96  forceinline int
97  SetVar::glbMax(void) const { return x->glbMax(); }
98 
99 
100 
101  /*
102  * Range and value iterators for set variables
103  *
104  */
105 
108 
111  : iter(s.varimp()) {}
112 
114  bool
115  SetVarGlbRanges::operator ()(void) const { return iter(); }
116 
118  void
120 
122  int
123  SetVarGlbRanges::min(void) const { return iter.min(); }
124 
126  int
127  SetVarGlbRanges::max(void) const { return iter.max(); }
128 
130  unsigned int
131  SetVarGlbRanges::width(void) const { return iter.width(); }
132 
135 
138  : iter(s.varimp()) {}
139 
141  bool
142  SetVarLubRanges::operator ()(void) const { return iter(); }
143 
145  void
147 
149  int
150  SetVarLubRanges::min(void) const { return iter.min(); }
151 
153  int
154  SetVarLubRanges::max(void) const { return iter.max(); }
155 
157  unsigned int
158  SetVarLubRanges::width(void) const { return iter.width(); }
159 
162 
165  iter.init(s.varimp());
166  }
167 
169  bool
170  SetVarUnknownRanges::operator ()(void) const { return iter(); }
171 
173  void
175 
177  int
178  SetVarUnknownRanges::min(void) const { return iter.min(); }
179 
181  int
182  SetVarUnknownRanges::max(void) const { return iter.max(); }
183 
185  unsigned int
186  SetVarUnknownRanges::width(void) const { return iter.width(); }
187 
190  SetVarGlbRanges ivr(x);
191  iter.init(ivr);
192  }
193 
194  forceinline bool
196  return iter();
197  }
198 
199  forceinline void
201  ++iter;
202  }
203 
204  forceinline int
205  SetVarGlbValues::val(void) const {
206  return iter.val();
207  }
208 
211  SetVarLubRanges ivr(x);
212  iter.init(ivr);
213  }
214 
215  forceinline bool
217  return iter();
218  }
219 
220  forceinline void
222  ++iter;
223  }
224 
225  forceinline int
226  SetVarLubValues::val(void) const {
227  return iter.val();
228  }
229 
232  SetVarUnknownRanges ivr(x);
233  iter.init(ivr);
234  }
235 
236  forceinline bool
238  return iter();
239  }
240 
241  forceinline void
243  ++iter;
244  }
245 
246  forceinline int
248  return iter.val();
249  }
250 
251 }
252 
253 // STATISTICS: set-var
254