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-08-31 17:19:33 +0200 (Tue, 31 Aug 2010) $ by $Author: schulte $ 00011 * $Revision: 11368 $ 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<BoolVar>(y.varimp()) {} 00049 forceinline 00050 BoolView::BoolView(BoolVarImp* y) 00051 : VarImpView<BoolVar>(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 return x->narrow_r(home,i,depend); 00181 } 00182 template<class I> 00183 forceinline ModEvent 00184 BoolView::inter_r(Space& home, I& i, bool depend) { 00185 return x->inter_r(home,i,depend); 00186 } 00187 template<class I> 00188 forceinline ModEvent 00189 BoolView::minus_r(Space& home, I& i, bool depend) { 00190 return x->minus_r(home,i,depend); 00191 } 00192 template<class I> 00193 forceinline ModEvent 00194 BoolView::narrow_v(Space& home, I& i, bool depend) { 00195 return x->narrow_v(home,i,depend); 00196 } 00197 template<class I> 00198 forceinline ModEvent 00199 BoolView::inter_v(Space& home, I& i, bool depend) { 00200 return x->inter_v(home,i,depend); 00201 } 00202 template<class I> 00203 forceinline ModEvent 00204 BoolView::minus_v(Space& home, I& i, bool depend) { 00205 return x->minus_v(home,i,depend); 00206 } 00207 00208 00209 /* 00210 * Boolean domain tests 00211 * 00212 */ 00213 forceinline bool 00214 BoolView::zero(void) const { 00215 return x->zero(); 00216 } 00217 forceinline bool 00218 BoolView::one(void) const { 00219 return x->one(); 00220 } 00221 forceinline bool 00222 BoolView::none(void) const { 00223 return x->none(); 00224 } 00225 00226 00227 /* 00228 * Boolean assignment operations 00229 * 00230 */ 00231 forceinline ModEvent 00232 BoolView::zero_none(Space& home) { 00233 return x->zero_none(home); 00234 } 00235 forceinline ModEvent 00236 BoolView::one_none(Space& home) { 00237 return x->one_none(home); 00238 } 00239 00240 forceinline ModEvent 00241 BoolView::zero(Space& home) { 00242 return x->zero(home); 00243 } 00244 forceinline ModEvent 00245 BoolView::one(Space& home) { 00246 return x->one(home); 00247 } 00248 00249 00250 /* 00251 * Delta information for advisors 00252 * 00253 */ 00254 forceinline int 00255 BoolView::min(const Delta& d) const { 00256 return BoolVarImp::min(d); 00257 } 00258 forceinline int 00259 BoolView::max(const Delta& d) const { 00260 return BoolVarImp::max(d); 00261 } 00262 forceinline bool 00263 BoolView::any(const Delta& d) const { 00264 return BoolVarImp::any(d); 00265 } 00266 forceinline bool 00267 BoolView::zero(const Delta& d) { 00268 return BoolVarImp::zero(d); 00269 } 00270 forceinline bool 00271 BoolView::one(const Delta& d) { 00272 return BoolVarImp::one(d); 00273 } 00274 00275 00276 00277 forceinline ModEventDelta 00278 BoolView::med(ModEvent me) { 00279 return VarImpView<BoolVar>::med(me); 00280 } 00281 00286 template<> 00287 class ViewRanges<BoolView> : public Iter::Ranges::Singleton { 00288 public: 00290 00291 00292 ViewRanges(void); 00294 ViewRanges(const BoolView& x); 00296 void init(const BoolView& x); 00298 }; 00299 00300 forceinline 00301 ViewRanges<BoolView>::ViewRanges(void) {} 00302 00303 forceinline 00304 ViewRanges<BoolView>::ViewRanges(const BoolView& x) 00305 : Iter::Ranges::Singleton(x.min(),x.max()) {} 00306 00307 forceinline void 00308 ViewRanges<BoolView>::init(const BoolView& x) { 00309 Iter::Ranges::Singleton::init(x.min(),x.max()); 00310 } 00311 00312 }} 00313 00314 // STATISTICS: int-var