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 * This file is part of Gecode, the generic constraint 00010 * development environment: 00011 * http://www.gecode.org 00012 * 00013 * Permission is hereby granted, free of charge, to any person obtaining 00014 * a copy of this software and associated documentation files (the 00015 * "Software"), to deal in the Software without restriction, including 00016 * without limitation the rights to use, copy, modify, merge, publish, 00017 * distribute, sublicense, and/or sell copies of the Software, and to 00018 * permit persons to whom the Software is furnished to do so, subject to 00019 * the following conditions: 00020 * 00021 * The above copyright notice and this permission notice shall be 00022 * included in all copies or substantial portions of the Software. 00023 * 00024 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00025 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00026 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00027 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00028 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00029 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00030 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00031 * 00032 */ 00033 00034 namespace Gecode { 00035 00036 forceinline void 00037 BoolVar::_init(Space& home, int min, int max) { 00038 assert((min >= 0) && (max <= 1) && (min <= max)); 00039 if (min > 0) 00040 x = &Int::BoolVarImp::s_one; 00041 else if (max == 0) 00042 x = &Int::BoolVarImp::s_zero; 00043 else 00044 x = new (home) Int::BoolVarImp(home,0,1); 00045 } 00046 00047 forceinline 00048 BoolVar::BoolVar(void) {} 00049 forceinline 00050 BoolVar::BoolVar(const BoolVar& y) 00051 : VarImpVar<Int::BoolVarImp>(y.varimp()) {} 00052 forceinline 00053 BoolVar::BoolVar(const Int::BoolView& y) 00054 : VarImpVar<Int::BoolVarImp>(y.varimp()) {} 00055 00056 forceinline int 00057 BoolVar::val(void) const { 00058 if (!x->assigned()) 00059 throw Int::ValOfUnassignedVar("BoolVar::val"); 00060 return x->val(); 00061 } 00062 forceinline int 00063 BoolVar::min(void) const { 00064 return x->min(); 00065 } 00066 forceinline int 00067 BoolVar::med(void) const { 00068 return x->med(); 00069 } 00070 forceinline int 00071 BoolVar::max(void) const { 00072 return x->max(); 00073 } 00074 00075 00076 forceinline unsigned int 00077 BoolVar::width(void) const { 00078 return x->width(); 00079 } 00080 forceinline unsigned int 00081 BoolVar::size(void) const { 00082 return x->size(); 00083 } 00084 forceinline unsigned int 00085 BoolVar::regret_min(void) const { 00086 return x->regret_min(); 00087 } 00088 forceinline unsigned int 00089 BoolVar::regret_max(void) const { 00090 return x->regret_max(); 00091 } 00092 00093 forceinline bool 00094 BoolVar::range(void) const { 00095 return x->range(); 00096 } 00097 forceinline bool 00098 BoolVar::in(int n) const { 00099 return x->in(n); 00100 } 00101 00102 forceinline bool 00103 BoolVar::zero(void) const { 00104 return x->zero(); 00105 } 00106 forceinline bool 00107 BoolVar::one(void) const { 00108 return x->one(); 00109 } 00110 forceinline bool 00111 BoolVar::none(void) const { 00112 return x->none(); 00113 } 00114 00115 } 00116 00117 // STATISTICS: int-var