this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Christian Schulte <schulte@gecode.org> 5 * 6 * Copyright: 7 * Christian Schulte, 2002 8 * 9 * This file is part of Gecode, the generic constraint 10 * development environment: 11 * http://www.gecode.org 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining 14 * a copy of this software and associated documentation files (the 15 * "Software"), to deal in the Software without restriction, including 16 * without limitation the rights to use, copy, modify, merge, publish, 17 * distribute, sublicense, and/or sell copies of the Software, and to 18 * permit persons to whom the Software is furnished to do so, subject to 19 * the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be 22 * included in all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 * 32 */ 33 34namespace Gecode { 35 36 forceinline void 37 BoolVar::_init(Space& home, int min, int max) { 38 assert((min >= 0) && (max <= 1) && (min <= max)); 39 if (min > 0) 40 x = &Int::BoolVarImp::s_one; 41 else if (max == 0) 42 x = &Int::BoolVarImp::s_zero; 43 else 44 x = new (home) Int::BoolVarImp(home,0,1); 45 } 46 47 forceinline 48 BoolVar::BoolVar(void) {} 49 forceinline 50 BoolVar::BoolVar(const BoolVar& y) 51 : VarImpVar<Int::BoolVarImp>(y.varimp()) {} 52 forceinline 53 BoolVar::BoolVar(const Int::BoolView& y) 54 : VarImpVar<Int::BoolVarImp>(y.varimp()) {} 55 56 forceinline int 57 BoolVar::val(void) const { 58 if (!x->assigned()) 59 throw Int::ValOfUnassignedVar("BoolVar::val"); 60 return x->val(); 61 } 62 forceinline int 63 BoolVar::min(void) const { 64 return x->min(); 65 } 66 forceinline int 67 BoolVar::med(void) const { 68 return x->med(); 69 } 70 forceinline int 71 BoolVar::max(void) const { 72 return x->max(); 73 } 74 75 76 forceinline unsigned int 77 BoolVar::width(void) const { 78 return x->width(); 79 } 80 forceinline unsigned int 81 BoolVar::size(void) const { 82 return x->size(); 83 } 84 forceinline unsigned int 85 BoolVar::regret_min(void) const { 86 return x->regret_min(); 87 } 88 forceinline unsigned int 89 BoolVar::regret_max(void) const { 90 return x->regret_max(); 91 } 92 93 forceinline bool 94 BoolVar::range(void) const { 95 return x->range(); 96 } 97 forceinline bool 98 BoolVar::in(int n) const { 99 return x->in(n); 100 } 101 102 forceinline bool 103 BoolVar::zero(void) const { 104 return x->zero(); 105 } 106 forceinline bool 107 BoolVar::one(void) const { 108 return x->one(); 109 } 110 forceinline bool 111 BoolVar::none(void) const { 112 return x->none(); 113 } 114 115} 116 117// STATISTICS: int-var