Generated on Mon Aug 25 11:35:44 2008 for Gecode by doxygen 1.5.6

set.icc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *     Gabor Szokoli <szokoli@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Guido Tack, 2004
00010  *     Christian Schulte, 2004
00011  *     Gabor Szokoli, 2004
00012  *
00013  *  Last modified:
00014  *     $Date: 2008-07-11 09:31:51 +0200 (Fri, 11 Jul 2008) $ by $Author: tack $
00015  *     $Revision: 7288 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 namespace Gecode {
00043 
00044   /*
00045    * Constructors and access
00046    *
00047    */
00048 
00049   forceinline
00050   SetVar::SetVar(void) {}
00051 
00052   forceinline
00053   SetVar::SetVar(const SetVar& x) 
00054     : VarBase<Set::SetVarImp>(x.varimp) {}
00055 
00056   forceinline
00057   SetVar::SetVar(const Set::SetView& x) 
00058     : VarBase<Set::SetVarImp>(x.var()) {}
00059 
00060   forceinline
00061   SetVar::SetVar(const Reflection::Var& x) 
00062     : VarBase<Set::SetVarImp>(x.var<Set::SetVarImp>()) {}
00063 
00064   forceinline void
00065   SetVar::init(Space* home) {
00066     varimp = new (home) Set::SetVarImp(home);
00067   }
00068 
00069   forceinline void
00070   SetVar::init(Space* home,int lbMin,int lbMax,int ubMin,int ubMax,
00071                unsigned int cardMin, unsigned int cardMax) {
00072     varimp = new (home) Set::SetVarImp(home, lbMin, lbMax, ubMin, ubMax,
00073                                        cardMin, cardMax);
00074   }
00075 
00076   forceinline void
00077   SetVar::init(Space* home, const IntSet& glb,int ubMin,int ubMax,
00078                unsigned int cardMin, unsigned int cardMax) {
00079     varimp = new (home) Set::SetVarImp(home, glb, ubMin, ubMax, 
00080                                        cardMin, cardMax);
00081   }
00082 
00083   forceinline void
00084   SetVar::init(Space* home, int lbMin,int lbMax,const IntSet& lub,
00085                unsigned int cardMin, unsigned int cardMax) {
00086     varimp = new (home) Set::SetVarImp(home, lbMin, lbMax, lub, 
00087                                        cardMin, cardMax);
00088   }
00089 
00090   forceinline void
00091   SetVar::init(Space* home, const IntSet& glb, const IntSet& lub,
00092                unsigned int cardMin, unsigned int cardMax) {
00093     varimp = new (home) Set::SetVarImp(home, glb, lub, cardMin, cardMax);
00094   }
00095 
00096 
00097 
00098   /*
00099    * Variable information
00100    *
00101    */
00102 
00103   forceinline unsigned int
00104   SetVar::glbSize(void) const { return varimp->glbSize(); }
00105 
00106   forceinline unsigned int
00107   SetVar::lubSize(void) const { return varimp->lubSize(); }
00108 
00109   forceinline unsigned int
00110   SetVar::unknownSize(void) const { return varimp->lubSize()-varimp->glbSize(); }
00111 
00112   forceinline bool
00113   SetVar::assigned(void)  const { return varimp->assigned(); }
00114 
00115   forceinline bool
00116   SetVar::contains(int i) const { return varimp->knownIn(i); }
00117 
00118   forceinline bool
00119   SetVar::notContains(int i) const { return varimp->knownOut(i); }
00120 
00121   forceinline unsigned int
00122   SetVar::cardMin(void) const { return varimp->cardMin(); }
00123 
00124   forceinline unsigned int
00125   SetVar::cardMax(void) const { return varimp->cardMax(); }
00126 
00127   forceinline int
00128   SetVar::lubMin(void) const { return varimp->lubMin(); }
00129 
00130   forceinline int
00131   SetVar::lubMax(void) const { return varimp->lubMax(); }
00132 
00133   forceinline int
00134   SetVar::glbMin(void) const { return varimp->glbMin(); }
00135 
00136   forceinline int
00137   SetVar::glbMax(void) const { return varimp->glbMax(); }
00138 
00139   /*
00140    * Cloning
00141    *
00142    */
00143 
00144   forceinline void
00145   SetVar::update(Space* home, bool share, SetVar& y) {
00146     varimp = y.varimp->copy(home,share);
00147   }
00148 
00149 
00150   /*
00151    * Range and value iterators for set variables
00152    *
00153    */
00154 
00155   forceinline
00156   SetVarGlbRanges::SetVarGlbRanges(void) {}
00157 
00158   forceinline
00159   SetVarGlbRanges::SetVarGlbRanges(const SetVar& s)
00160     : iter(s.var()) {}
00161 
00162   forceinline
00163   bool
00164   SetVarGlbRanges::operator()(void) const { return iter(); }
00165 
00166   forceinline
00167   void
00168   SetVarGlbRanges::operator++(void) { ++iter; }
00169 
00170   forceinline
00171   int
00172   SetVarGlbRanges::min(void) const { return iter.min(); }
00173 
00174   forceinline
00175   int
00176   SetVarGlbRanges::max(void) const { return iter.max(); }
00177 
00178   forceinline
00179   unsigned int
00180   SetVarGlbRanges::width(void) const { return iter.width(); }  
00181 
00182   forceinline
00183   SetVarLubRanges::SetVarLubRanges(void) {}
00184 
00185   forceinline
00186   SetVarLubRanges::SetVarLubRanges(const SetVar& s)
00187     : iter(s.var()) {}
00188 
00189   forceinline
00190   bool
00191   SetVarLubRanges::operator()(void) const { return iter(); }
00192 
00193   forceinline
00194   void
00195   SetVarLubRanges::operator++(void) { ++iter; }
00196 
00197   forceinline
00198   int
00199   SetVarLubRanges::min(void) const { return iter.min(); }
00200 
00201   forceinline
00202   int
00203   SetVarLubRanges::max(void) const { return iter.max(); }
00204 
00205   forceinline
00206   unsigned int
00207   SetVarLubRanges::width(void) const { return iter.width(); }  
00208 
00209   forceinline
00210   SetVarUnknownRanges::SetVarUnknownRanges(void) {}
00211 
00212   forceinline
00213   SetVarUnknownRanges::SetVarUnknownRanges(const SetVar& s) {
00214     iter.init(s.var());
00215   }
00216 
00217   forceinline
00218   bool
00219   SetVarUnknownRanges::operator()(void) const { return iter(); }
00220 
00221   forceinline
00222   void
00223   SetVarUnknownRanges::operator++(void) { ++iter; }
00224 
00225   forceinline
00226   int
00227   SetVarUnknownRanges::min(void) const { return iter.min(); }
00228 
00229   forceinline
00230   int
00231   SetVarUnknownRanges::max(void) const { return iter.max(); }
00232 
00233   forceinline
00234   unsigned int
00235   SetVarUnknownRanges::width(void) const { return iter.width(); }  
00236 
00237   forceinline
00238   SetVarGlbValues::SetVarGlbValues(const SetVar& x) {
00239     SetVarGlbRanges ivr(x);
00240     iter.init(ivr);
00241   }
00242 
00243   forceinline bool
00244   SetVarGlbValues::operator()(void) const {
00245     return iter();
00246   }
00247 
00248   forceinline void
00249   SetVarGlbValues::operator++(void) {
00250     ++iter;
00251   }
00252 
00253   forceinline int
00254   SetVarGlbValues::val(void) const {
00255     return iter.val();
00256   }
00257 
00258   forceinline
00259   SetVarLubValues::SetVarLubValues(const SetVar& x) {
00260     SetVarLubRanges ivr(x);
00261     iter.init(ivr);
00262   }
00263 
00264   forceinline bool
00265   SetVarLubValues::operator()(void) const {
00266     return iter();
00267   }
00268 
00269   forceinline void
00270   SetVarLubValues::operator++(void) {
00271     ++iter;
00272   }
00273 
00274   forceinline int
00275   SetVarLubValues::val(void) const {
00276     return iter.val();
00277   }
00278 
00279   forceinline
00280   SetVarUnknownValues::SetVarUnknownValues(const SetVar& x) {
00281     SetVarUnknownRanges ivr(x);
00282     iter.init(ivr);
00283   }
00284 
00285   forceinline bool
00286   SetVarUnknownValues::operator()(void) const {
00287     return iter();
00288   }
00289 
00290   forceinline void
00291   SetVarUnknownValues::operator++(void) {
00292     ++iter;
00293   }
00294 
00295   forceinline int
00296   SetVarUnknownValues::val(void) const {
00297     return iter.val();
00298   }
00299 
00300 }
00301 
00302 // STATISTICS: set-var
00303