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 IntVar::_init(Space& home, int min, int max) { 38 x = new (home) Int::IntVarImp(home,min,max); 39 } 40 41 forceinline void 42 IntVar::_init(Space& home, const IntSet& ds) { 43 x = new (home) Int::IntVarImp(home,ds); 44 } 45 46 forceinline 47 IntVar::IntVar(void) {} 48 forceinline 49 IntVar::IntVar(const IntVar& y) 50 : VarImpVar<Int::IntVarImp>(y.varimp()) {} 51 forceinline 52 IntVar::IntVar(const Int::IntView& y) 53 : VarImpVar<Int::IntVarImp>(y.varimp()) {} 54 55 forceinline int 56 IntVar::val(void) const { 57 if (!x->assigned()) 58 throw Int::ValOfUnassignedVar("IntVar::val"); 59 return x->val(); 60 } 61 forceinline int 62 IntVar::min(void) const { 63 return x->min(); 64 } 65 forceinline int 66 IntVar::med(void) const { 67 return x->med(); 68 } 69 forceinline int 70 IntVar::max(void) const { 71 return x->max(); 72 } 73 74 75 forceinline unsigned int 76 IntVar::width(void) const { 77 return x->width(); 78 } 79 forceinline unsigned int 80 IntVar::size(void) const { 81 return x->size(); 82 } 83 forceinline unsigned int 84 IntVar::regret_min(void) const { 85 return x->regret_min(); 86 } 87 forceinline unsigned int 88 IntVar::regret_max(void) const { 89 return x->regret_max(); 90 } 91 92 forceinline bool 93 IntVar::range(void) const { 94 return x->range(); 95 } 96 forceinline bool 97 IntVar::in(int n) const { 98 return x->in(n); 99 } 100 101 /* 102 * Range iterator 103 * 104 */ 105 forceinline 106 IntVarRanges::IntVarRanges(void) {} 107 108 forceinline 109 IntVarRanges::IntVarRanges(const IntVar& x) 110 : Int::IntVarImpFwd(x.varimp()) {} 111 112 forceinline void 113 IntVarRanges::init(const IntVar& x) { 114 Int::IntVarImpFwd::init(x.varimp()); 115 } 116 117 118 /* 119 * Value iterator 120 * 121 */ 122 123 forceinline 124 IntVarValues::IntVarValues(void) {} 125 126 forceinline 127 IntVarValues::IntVarValues(const IntVar& x) { 128 IntVarRanges r(x); 129 Iter::Ranges::ToValues<IntVarRanges>::init(r); 130 } 131 132 forceinline void 133 IntVarValues::init(const IntVar& x) { 134 IntVarRanges r(x); 135 Iter::Ranges::ToValues<IntVarRanges>::init(r); 136 } 137 138} 139 140// STATISTICS: int-var 141