bool.hpp
Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Christian Schulte <schulte@gecode.org> 00005 * 00006 * Copyright: 00007 * Christian Schulte, 2002 00008 * 00009 * Last modified: 00010 * $Date: 2010-06-29 10:39:13 +0200 (Tue, 29 Jun 2010) $ by $Author: schulte $ 00011 * $Revision: 11118 $ 00012 * 00013 * This file is part of Gecode, the generic constraint 00014 * development environment: 00015 * http://www.gecode.org 00016 * 00017 * Permission is hereby granted, free of charge, to any person obtaining 00018 * a copy of this software and associated documentation files (the 00019 * "Software"), to deal in the Software without restriction, including 00020 * without limitation the rights to use, copy, modify, merge, publish, 00021 * distribute, sublicense, and/or sell copies of the Software, and to 00022 * permit persons to whom the Software is furnished to do so, subject to 00023 * the following conditions: 00024 * 00025 * The above copyright notice and this permission notice shall be 00026 * included in all copies or substantial portions of the Software. 00027 * 00028 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00029 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00030 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00031 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00032 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00033 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00034 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00035 * 00036 */ 00037 00038 namespace Gecode { namespace Int { 00039 00040 /* 00041 * Constructors and initialization 00042 * 00043 */ 00044 forceinline 00045 BoolView::BoolView(void) {} 00046 forceinline 00047 BoolView::BoolView(const BoolVar& y) 00048 : VarImpView<BoolVarImp>(y.varimp()) {} 00049 forceinline 00050 BoolView::BoolView(BoolVarImp* y) 00051 : VarImpView<BoolVarImp>(y) {} 00052 00053 /* 00054 * Value access 00055 * 00056 */ 00057 forceinline BoolStatus 00058 BoolView::status(void) const { 00059 return x->status(); 00060 } 00061 forceinline int 00062 BoolView::min(void) const { 00063 return x->min(); 00064 } 00065 forceinline int 00066 BoolView::max(void) const { 00067 return x->max(); 00068 } 00069 forceinline int 00070 BoolView::med(void) const { 00071 return x->med(); 00072 } 00073 forceinline int 00074 BoolView::val(void) const { 00075 return x->val(); 00076 } 00077 00078 forceinline unsigned int 00079 BoolView::size(void) const { 00080 return x->size(); 00081 } 00082 forceinline unsigned int 00083 BoolView::width(void) const { 00084 return x->width(); 00085 } 00086 forceinline unsigned int 00087 BoolView::regret_min(void) const { 00088 return x->regret_min(); 00089 } 00090 forceinline unsigned int 00091 BoolView::regret_max(void) const { 00092 return x->regret_max(); 00093 } 00094 00095 00096 /* 00097 * Domain tests 00098 * 00099 */ 00100 forceinline bool 00101 BoolView::range(void) const { 00102 return x->range(); 00103 } 00104 forceinline bool 00105 BoolView::in(int n) const { 00106 return x->in(n); 00107 } 00108 forceinline bool 00109 BoolView::in(double n) const { 00110 return x->in(n); 00111 } 00112 00113 00114 /* 00115 * Domain update by value 00116 * 00117 */ 00118 forceinline ModEvent 00119 BoolView::lq(Space& home, int n) { 00120 return x->lq(home,n); 00121 } 00122 forceinline ModEvent 00123 BoolView::lq(Space& home, double n) { 00124 return x->lq(home,n); 00125 } 00126 00127 forceinline ModEvent 00128 BoolView::le(Space& home, int n) { 00129 return x->lq(home,n-1); 00130 } 00131 forceinline ModEvent 00132 BoolView::le(Space& home, double n) { 00133 return lq(home,n-1.0); 00134 } 00135 00136 forceinline ModEvent 00137 BoolView::gq(Space& home, int n) { 00138 return x->gq(home,n); 00139 } 00140 forceinline ModEvent 00141 BoolView::gq(Space& home, double n) { 00142 return x->gq(home,n); 00143 } 00144 00145 forceinline ModEvent 00146 BoolView::gr(Space& home, int n) { 00147 return x->gq(home,n+1); 00148 } 00149 forceinline ModEvent 00150 BoolView::gr(Space& home, double n) { 00151 return gq(home,n+1.0); 00152 } 00153 00154 forceinline ModEvent 00155 BoolView::nq(Space& home, int n) { 00156 return x->nq(home,n); 00157 } 00158 forceinline ModEvent 00159 BoolView::nq(Space& home, double n) { 00160 return x->nq(home,n); 00161 } 00162 00163 forceinline ModEvent 00164 BoolView::eq(Space& home, int n) { 00165 return x->eq(home,n); 00166 } 00167 forceinline ModEvent 00168 BoolView::eq(Space& home, double n) { 00169 return x->eq(home,n); 00170 } 00171 00172 00173 /* 00174 * Iterator-based domain update 00175 * 00176 */ 00177 template<class I> 00178 forceinline ModEvent 00179 BoolView::narrow_r(Space& home, I& i, bool depend) { 00180 Iter::Ranges::IsRangeIter<I>(); 00181 return x->narrow_r(home,i,depend); 00182 } 00183 template<class I> 00184 forceinline ModEvent 00185 BoolView::inter_r(Space& home, I& i, bool depend) { 00186 Iter::Ranges::IsRangeIter<I>(); 00187 return x->inter_r(home,i,depend); 00188 } 00189 template<class I> 00190 forceinline ModEvent 00191 BoolView::minus_r(Space& home, I& i, bool depend) { 00192 Iter::Ranges::IsRangeIter<I>(); 00193 return x->minus_r(home,i,depend); 00194 } 00195 template<class I> 00196 forceinline ModEvent 00197 BoolView::narrow_v(Space& home, I& i, bool depend) { 00198 Iter::Values::IsValueIter<I>(); 00199 return x->narrow_v(home,i,depend); 00200 } 00201 template<class I> 00202 forceinline ModEvent 00203 BoolView::inter_v(Space& home, I& i, bool depend) { 00204 Iter::Values::IsValueIter<I>(); 00205 return x->inter_v(home,i,depend); 00206 } 00207 template<class I> 00208 forceinline ModEvent 00209 BoolView::minus_v(Space& home, I& i, bool depend) { 00210 Iter::Values::IsValueIter<I>(); 00211 return x->minus_v(home,i,depend); 00212 } 00213 00214 00215 /* 00216 * Boolean domain tests 00217 * 00218 */ 00219 forceinline bool 00220 BoolView::zero(void) const { 00221 return x->zero(); 00222 } 00223 forceinline bool 00224 BoolView::one(void) const { 00225 return x->one(); 00226 } 00227 forceinline bool 00228 BoolView::none(void) const { 00229 return x->none(); 00230 } 00231 00232 00233 /* 00234 * Boolean assignment operations 00235 * 00236 */ 00237 forceinline ModEvent 00238 BoolView::zero_none(Space& home) { 00239 return x->zero_none(home); 00240 } 00241 forceinline ModEvent 00242 BoolView::one_none(Space& home) { 00243 return x->one_none(home); 00244 } 00245 00246 forceinline ModEvent 00247 BoolView::zero(Space& home) { 00248 return x->zero(home); 00249 } 00250 forceinline ModEvent 00251 BoolView::one(Space& home) { 00252 return x->one(home); 00253 } 00254 00255 00256 /* 00257 * Delta information for advisors 00258 * 00259 */ 00260 forceinline int 00261 BoolView::min(const Delta& d) const { 00262 return BoolVarImp::min(d); 00263 } 00264 forceinline int 00265 BoolView::max(const Delta& d) const { 00266 return BoolVarImp::max(d); 00267 } 00268 forceinline bool 00269 BoolView::any(const Delta& d) const { 00270 return BoolVarImp::any(d); 00271 } 00272 forceinline bool 00273 BoolView::zero(const Delta& d) { 00274 return BoolVarImp::zero(d); 00275 } 00276 forceinline bool 00277 BoolView::one(const Delta& d) { 00278 return BoolVarImp::one(d); 00279 } 00280 00281 00282 00283 forceinline ModEventDelta 00284 BoolView::med(ModEvent me) { 00285 return VarImpView<BoolVarImp>::med(me); 00286 } 00287 00292 template<> 00293 class ViewRanges<BoolView> : public Iter::Ranges::Singleton { 00294 public: 00296 00297 00298 ViewRanges(void); 00300 ViewRanges(const BoolView& x); 00302 void init(const BoolView& x); 00304 }; 00305 00306 forceinline 00307 ViewRanges<BoolView>::ViewRanges(void) {} 00308 00309 forceinline 00310 ViewRanges<BoolView>::ViewRanges(const BoolView& x) 00311 : Iter::Ranges::Singleton(x.min(),x.max()) {} 00312 00313 forceinline void 00314 ViewRanges<BoolView>::init(const BoolView& x) { 00315 Iter::Ranges::Singleton::init(x.min(),x.max()); 00316 } 00317 00318 }} 00319 00320 // STATISTICS: int-var