int.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 IntVar::_init(Space& home, int min, int max) { 00038 x = new (home) Int::IntVarImp(home,min,max); 00039 } 00040 00041 forceinline void 00042 IntVar::_init(Space& home, const IntSet& ds) { 00043 x = new (home) Int::IntVarImp(home,ds); 00044 } 00045 00046 forceinline 00047 IntVar::IntVar(void) {} 00048 forceinline 00049 IntVar::IntVar(const IntVar& y) 00050 : VarImpVar<Int::IntVarImp>(y.varimp()) {} 00051 forceinline 00052 IntVar::IntVar(const Int::IntView& y) 00053 : VarImpVar<Int::IntVarImp>(y.varimp()) {} 00054 00055 forceinline int 00056 IntVar::val(void) const { 00057 if (!x->assigned()) 00058 throw Int::ValOfUnassignedVar("IntVar::val"); 00059 return x->val(); 00060 } 00061 forceinline int 00062 IntVar::min(void) const { 00063 return x->min(); 00064 } 00065 forceinline int 00066 IntVar::med(void) const { 00067 return x->med(); 00068 } 00069 forceinline int 00070 IntVar::max(void) const { 00071 return x->max(); 00072 } 00073 00074 00075 forceinline unsigned int 00076 IntVar::width(void) const { 00077 return x->width(); 00078 } 00079 forceinline unsigned int 00080 IntVar::size(void) const { 00081 return x->size(); 00082 } 00083 forceinline unsigned int 00084 IntVar::regret_min(void) const { 00085 return x->regret_min(); 00086 } 00087 forceinline unsigned int 00088 IntVar::regret_max(void) const { 00089 return x->regret_max(); 00090 } 00091 00092 forceinline bool 00093 IntVar::range(void) const { 00094 return x->range(); 00095 } 00096 forceinline bool 00097 IntVar::in(int n) const { 00098 return x->in(n); 00099 } 00100 00101 /* 00102 * Range iterator 00103 * 00104 */ 00105 forceinline 00106 IntVarRanges::IntVarRanges(void) {} 00107 00108 forceinline 00109 IntVarRanges::IntVarRanges(const IntVar& x) 00110 : Int::IntVarImpFwd(x.varimp()) {} 00111 00112 forceinline void 00113 IntVarRanges::init(const IntVar& x) { 00114 Int::IntVarImpFwd::init(x.varimp()); 00115 } 00116 00117 00118 /* 00119 * Value iterator 00120 * 00121 */ 00122 00123 forceinline 00124 IntVarValues::IntVarValues(void) {} 00125 00126 forceinline 00127 IntVarValues::IntVarValues(const IntVar& x) { 00128 IntVarRanges r(x); 00129 Iter::Ranges::ToValues<IntVarRanges>::init(r); 00130 } 00131 00132 forceinline void 00133 IntVarValues::init(const IntVar& x) { 00134 IntVarRanges r(x); 00135 Iter::Ranges::ToValues<IntVarRanges>::init(r); 00136 } 00137 00138 } 00139 00140 // STATISTICS: int-var 00141