gecode » set » view

00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Guido Tack <tack@gecode.org> 00005 * 00006 * Contributing authors: 00007 * Christian Schulte <schulte@gecode.org> 00008 * Gabor Szokoli <szokoli@gecode.org> 00009 * 00010 * Copyright: 00011 * Guido Tack, 2004 00012 * Christian Schulte, 2004 00013 * Gabor Szokoli, 2004 00014 * 00015 * Last modified: 00016 * $Date: 2009-09-08 21:10:29 +0200 (Tue, 08 Sep 2009) $ by $Author: schulte $ 00017 * $Revision: 9692 $ 00018 * 00019 * This file is part of Gecode, the generic constraint 00020 * development environment: 00021 * http://www.gecode.org 00022 * 00023 * Permission is hereby granted, free of charge, to any person obtaining 00024 * a copy of this software and associated documentation files (the 00025 * "Software"), to deal in the Software without restriction, including 00026 * without limitation the rights to use, copy, modify, merge, publish, 00027 * distribute, sublicense, and/or sell copies of the Software, and to 00028 * permit persons to whom the Software is furnished to do so, subject to 00029 * the following conditions: 00030 * 00031 * The above copyright notice and this permission notice shall be 00032 * included in all copies or substantial portions of the Software. 00033 * 00034 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00035 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00036 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00037 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00038 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00039 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00040 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00041 * 00042 */ 00043 00044 namespace Gecode { namespace Set { 00045 00046 /* 00047 * Constructors and access 00048 * 00049 */ 00050 00051 forceinline 00052 SetView::SetView(void) {} 00053 forceinline 00054 SetView::SetView(const SetVar& y) 00055 : VarViewBase<SetVarImp>(y.var()) {} 00056 forceinline 00057 SetView::SetView(SetVarImp* y) 00058 : VarViewBase<SetVarImp>(y) {} 00059 00060 /* 00061 * Variable information 00062 * 00063 */ 00064 00065 forceinline bool 00066 SetView::assigned(void) const { 00067 return varimp->assigned(); 00068 } 00069 00070 forceinline unsigned int 00071 SetView::glbSize(void) const { return varimp->glbSize(); } 00072 00073 forceinline unsigned int 00074 SetView::lubSize(void) const { return varimp->lubSize(); } 00075 00076 forceinline unsigned int 00077 SetView::unknownSize(void) const { return varimp->lubSize() - varimp->glbSize(); } 00078 00079 forceinline bool 00080 SetView::contains(int i) const { return (varimp->knownIn(i)); } 00081 00082 forceinline bool 00083 SetView::notContains(int i) const { return (varimp->knownOut(i)); } 00084 00085 forceinline unsigned int 00086 SetView::cardMin(void) const { return varimp->cardMin(); } 00087 00088 forceinline unsigned int 00089 SetView::cardMax(void) const { return varimp->cardMax(); } 00090 00091 forceinline int 00092 SetView::lubMin(void) const { return varimp->lubMin(); } 00093 00094 forceinline int 00095 SetView::lubMax(void) const { return varimp->lubMax(); } 00096 00097 forceinline int 00098 SetView::lubMinN(unsigned int n) const { return varimp->lubMinN(n); } 00099 00100 forceinline int 00101 SetView::glbMin(void) const { return varimp->glbMin(); } 00102 00103 forceinline int 00104 SetView::glbMax(void) const { return varimp->glbMax(); } 00105 00106 /* 00107 * Tells 00108 * 00109 */ 00110 00111 forceinline ModEvent 00112 SetView::cardMin(Space& home, unsigned int m) { 00113 return varimp-> cardMin(home, m); 00114 } 00115 00116 forceinline ModEvent 00117 SetView::cardMax(Space& home, unsigned int m) { 00118 return varimp-> cardMax(home, m); 00119 } 00120 00121 forceinline ModEvent 00122 SetView::include (Space& home,int from, int to) { 00123 return (varimp->include(home,from,to)); 00124 } 00125 00126 forceinline ModEvent 00127 SetView::include (Space& home,int n) { 00128 return (varimp->include(home,n)); 00129 } 00130 00131 forceinline ModEvent 00132 SetView::exclude (Space& home,int n) { 00133 return (varimp->exclude(home, n)); 00134 } 00135 00136 forceinline ModEvent 00137 SetView::intersect (Space& home,int from, int to) { 00138 return (varimp->intersect(home,from,to)); 00139 } 00140 00141 forceinline ModEvent 00142 SetView::intersect (Space& home,int n) { 00143 return (varimp->intersect(home,n)); 00144 } 00145 00146 template<class I> ModEvent 00147 SetView::includeI (Space& home, I& iter) { 00148 Iter::Ranges::IsRangeIter<I>(); 00149 return (varimp->includeI(home, iter)); 00150 } 00151 00152 forceinline ModEvent 00153 SetView::exclude (Space& home,int from, int to) 00154 { return (varimp->exclude(home,from,to)); } 00155 00156 template<class I> ModEvent 00157 SetView::excludeI(Space& home, I& iter) { 00158 Iter::Ranges::IsRangeIter<I>(); 00159 return varimp->excludeI(home, iter); 00160 } 00161 00162 template<class I> ModEvent 00163 SetView::intersectI(Space& home, I& iter) { 00164 Iter::Ranges::IsRangeIter<I>(); 00165 return varimp->intersectI(home, iter); 00166 } 00167 00168 00169 00170 /* 00171 * Cloning 00172 * 00173 */ 00174 00175 forceinline void 00176 SetView::update(Space& home, bool share, SetView& y) { 00177 varimp = y.varimp->copy(home,share); 00178 } 00179 00180 00181 /* 00182 * Delta information for advisors 00183 * 00184 */ 00185 00186 forceinline ModEvent 00187 SetView::modevent(const Delta& d) { return SetVarImp::modevent(d); } 00188 00189 forceinline int 00190 SetView::glbMin(const Delta& d) const { return SetVarImp::glbMin(d); } 00191 00192 forceinline int 00193 SetView::glbMax(const Delta& d) const { return SetVarImp::glbMax(d); } 00194 00195 forceinline bool 00196 SetView::glbAny(const Delta& d) const { return SetVarImp::glbAny(d); } 00197 00198 forceinline int 00199 SetView::lubMin(const Delta& d) const { return SetVarImp::lubMin(d); } 00200 00201 forceinline int 00202 SetView::lubMax(const Delta& d) const { return SetVarImp::lubMax(d); } 00203 00204 forceinline bool 00205 SetView::lubAny(const Delta& d) const { return SetVarImp::lubAny(d); } 00206 00207 00212 template<> 00213 class LubRanges<SetView> : public LubRanges<SetVarImp*> { 00214 public: 00216 00217 00218 LubRanges(void); 00220 LubRanges(const SetView& x); 00222 void init(const SetView& x); 00224 }; 00225 00226 forceinline 00227 LubRanges<SetView>::LubRanges(void) {} 00228 00229 forceinline 00230 LubRanges<SetView>::LubRanges(const SetView& x) 00231 : LubRanges<SetVarImp*>(x.var()) {} 00232 00233 forceinline void 00234 LubRanges<SetView>::init(const SetView& x) { 00235 LubRanges<SetVarImp*>::init(x.var()); 00236 } 00237 00238 00243 template<> 00244 class GlbRanges<SetView> : public GlbRanges<SetVarImp*> { 00245 public: 00247 00248 00249 GlbRanges(void); 00251 GlbRanges(const SetView& x); 00253 void init(const SetView& x); 00254 }; 00255 00256 forceinline 00257 GlbRanges<SetView>::GlbRanges(void) {} 00258 00259 forceinline 00260 GlbRanges<SetView>::GlbRanges(const SetView& x) 00261 : GlbRanges<SetVarImp*>(x.var()) {} 00262 00263 forceinline void 00264 GlbRanges<SetView>::init(const SetView& x) { 00265 GlbRanges<SetVarImp*>::init(x.var()); 00266 } 00267 00268 }} 00269 00270 // STATISTICS: set-var 00271