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

const.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  *
00006  *  Copyright:
00007  *     Guido Tack, 2004
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-02-18 14:14:41 +0100 (Mon, 18 Feb 2008) $ by $Author: tack $
00011  *     $Revision: 6212 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode { namespace Set {
00039 
00044   class ArrayRanges {
00045   private:
00046     int *_ranges;
00047     int _size;
00048     int _pos;
00049   public:
00051 
00052 
00053     ArrayRanges(void) : _ranges(NULL), _size(0), _pos(0) {}
00055     ArrayRanges(int *ranges, int size)
00056       : _ranges(ranges), _size(size), _pos(0) {}
00058     void init(int* ranges, int size) {
00059       _ranges = ranges; _size = size; _pos = 0;
00060     }
00062 
00064 
00065 
00066     bool operator()(void) const { return _pos<_size; }
00068     void operator++(void) { _pos++; }
00070 
00072 
00073 
00074     int min(void) const { return _ranges[_pos*2]; }
00076     int max(void) const { return _ranges[_pos*2+1]; }
00078     unsigned int width(void) const {
00079       return _ranges[_pos*2+1]-_ranges[_pos*2]+1;
00080     }
00082   };
00083 
00084   forceinline
00085   ConstantView::ConstantView(void) : ranges(NULL), size(0), domSize(0) {}
00086 
00087   forceinline
00088   void
00089   ConstantView::init(Space* home, const IntSet& dom) {
00090     size = dom.size();
00091     domSize = 0;
00092     if (size > 0) {
00093       ranges = static_cast<int*>(home->alloc(2*size*sizeof(int)));
00094       IntSetRanges dr(dom);
00095       for (int i=0; dr(); ++dr, i+=2) {
00096         int min = dr.min(); int max = dr.max();
00097         ranges[i] = min;
00098         ranges[i+1] = max;
00099         domSize += (max-min+1);
00100       }
00101     } else {
00102       ranges = NULL;
00103     }
00104   }
00105 
00106   forceinline
00107   ConstantView::ConstantView(Space* home, const IntSet& dom) {
00108     init(home, dom);
00109   }
00110 
00111   forceinline
00112   ConstantView::ConstantView(Space* home,
00113                              const Reflection::VarMap&,
00114                              Reflection::Arg* arg) {
00115     Reflection::IntArrayArgRanges r(arg->toIntArray());
00116     IntSet is(r);
00117     init(home, is);
00118   }
00119 
00120   forceinline bool
00121   ConstantView::assigned(void) const { return true; }
00122 
00123   forceinline unsigned int
00124   ConstantView::glbSize(void) const { return domSize; }
00125 
00126   forceinline unsigned int
00127   ConstantView::lubSize(void) const { return domSize; }
00128 
00129   forceinline unsigned int
00130   ConstantView::unknownSize(void) const { return 0; }
00131 
00132   forceinline bool
00133   ConstantView::contains(int i) const {
00134     for (unsigned int j=size; j--; ) {
00135       if (ranges[2*j+1] < i)
00136         return false;
00137       if (ranges[2*j] >= i)
00138         return true;
00139     }
00140     return false;
00141   }
00142 
00143   forceinline bool
00144   ConstantView::notContains(int i) const {
00145     return !contains(i);
00146   }
00147 
00148   forceinline unsigned int
00149   ConstantView::cardMin(void) const { return domSize; }
00150 
00151   forceinline unsigned int
00152   ConstantView::cardMax(void) const { return domSize; }
00153 
00154   forceinline int
00155   ConstantView::lubMin(void) const {
00156     return size==0 ? BndSet::MIN_OF_EMPTY : ranges[0];
00157   }
00158 
00159   forceinline int
00160   ConstantView::lubMax(void) const {
00161     return size==0 ? BndSet::MAX_OF_EMPTY : ranges[size*2-1];
00162   }
00163 
00164   forceinline int
00165   ConstantView::glbMin(void) const { return lubMin(); }
00166 
00167   forceinline int
00168   ConstantView::glbMax(void) const { return lubMax(); }
00169 
00170   forceinline ModEvent
00171   ConstantView::cardMin(Space*,unsigned int c) {
00172     return c<=domSize ? ME_SET_NONE : ME_SET_FAILED;
00173   }
00174 
00175   forceinline ModEvent
00176   ConstantView::cardMax(Space*,unsigned int c) {
00177     return c>=domSize ? ME_SET_NONE : ME_SET_FAILED;
00178   }
00179 
00180   forceinline ModEvent
00181   ConstantView::include(Space*,int c) {
00182     return contains(c) ? ME_SET_NONE : ME_SET_FAILED;
00183   }
00184 
00185   forceinline ModEvent
00186   ConstantView::exclude(Space*,int c) {
00187     return contains(c) ? ME_SET_FAILED : ME_SET_NONE;
00188   }
00189 
00190   forceinline ModEvent
00191   ConstantView::intersect(Space*,int c) {
00192     return (size==0 ||
00193             (size==1 &&
00194              ranges[0]==ranges[1] && ranges[0]==c)) ?
00195       ME_SET_NONE : ME_SET_FAILED;
00196   }
00197 
00198   forceinline ModEvent
00199   ConstantView::intersect(Space*,int i,int j) {
00200     return (glbMin()>=i && glbMax()<=j) ?
00201       ME_SET_NONE : ME_SET_FAILED;
00202   }
00203 
00204   forceinline ModEvent
00205   ConstantView::include(Space*,int i,int j) {
00206     Iter::Ranges::Singleton single(i,j);
00207     ArrayRanges ar(ranges, size);
00208     return (single() && Iter::Ranges::subset(single, ar)) ?
00209       ME_SET_NONE : ME_SET_FAILED;
00210   }
00211 
00212   forceinline ModEvent
00213   ConstantView::exclude(Space*,int i,int j) {
00214     Iter::Ranges::Singleton single(i,j);
00215     ArrayRanges ar(ranges, size);
00216     return (single() && Iter::Ranges::subset(single, ar)) ?
00217       ME_SET_FAILED : ME_SET_NONE;
00218   }
00219 
00220   template <class I> ModEvent
00221   ConstantView::excludeI(Space*,I& i) {
00222     ArrayRanges ar(ranges, size);
00223     return (i() && Iter::Ranges::subset(i, ar)) ? ME_SET_FAILED : ME_SET_NONE;
00224   }
00225 
00226   template <class I> ModEvent
00227   ConstantView::includeI(Space*,I& i) {
00228     ArrayRanges ar(ranges, size);
00229     return Iter::Ranges::subset(i, ar) ? ME_SET_NONE : ME_SET_FAILED;
00230   }
00231 
00232   template <class I> ModEvent
00233   ConstantView::intersectI(Space*,I& i) {
00234     ArrayRanges ar(ranges, size);
00235     return Iter::Ranges::subset(ar, i) ? ME_SET_NONE : ME_SET_FAILED;
00236   }
00237 
00238   forceinline void
00239   ConstantView::schedule(Space* home, Propagator* p, ModEvent me) {
00240     return SetView::schedule(home,p,me);
00241   }
00242   forceinline ModEvent
00243   ConstantView::me(ModEventDelta) {
00244     return ME_SET_NONE;
00245   }
00246   forceinline ModEventDelta
00247   ConstantView::med(ModEvent me) {
00248     return SetVarImp::med(me);
00249   }
00250 
00251   forceinline void
00252   ConstantView::subscribe(Space* home, Propagator* p, PropCond,bool) {
00253     schedule(home,p,ME_SET_VAL);    
00254   }
00255   forceinline void
00256   ConstantView::cancel(Space*,Propagator*,PropCond) {}
00257 
00258   forceinline void
00259   ConstantView::subscribe(Space*, Advisor*) {}
00260   forceinline void
00261   ConstantView::cancel(Space*,Advisor*) {}
00262 
00263   forceinline void
00264   ConstantView::update(Space* home, bool, ConstantView& p) {
00265     // dispose old ranges
00266     if (size>0) {
00267       home->reuse(ranges, 2*size*sizeof(int));
00268     }
00269 
00270     domSize = p.domSize;
00271     size = p.size;
00272     if (size == 0) {
00273       ranges = NULL;
00274     } else {
00275       // copy ranges from p
00276       ranges = static_cast<int*>(home->alloc(2*size*sizeof(int)));
00277       for (unsigned int i=size; i--; ) {
00278         ranges[2*i]   = p.ranges[2*i];
00279         ranges[2*i+1] = p.ranges[2*i+1];
00280       }
00281     }
00282   }
00283 
00284   forceinline Reflection::Arg*
00285   ConstantView::spec(const Space*, Reflection::VarMap&) const {
00286     int count = 0;
00287     for (ArrayRanges ars(ranges, size); ars(); ++ars) {
00288       count++;
00289     }
00290     Reflection::IntArrayArg* args = Reflection::Arg::newIntArray(count*2);
00291     count = 0;
00292     for (ArrayRanges ars(ranges, size); ars(); ++ars) {
00293       (*args)[count++] = ars.min();
00294       (*args)[count++] = ars.max();
00295     }
00296     return args;
00297   }
00298 
00299   inline Support::Symbol
00300   ConstantView::type(void) {
00301     return Support::Symbol("Gecode::Set::ConstantView");
00302   }
00303 
00304   /*
00305    * Delta information for advisors
00306    *
00307    */
00308 
00309   forceinline ModEvent
00310   ConstantView::modevent(const Delta*) {
00311     GECODE_NEVER;
00312     return ME_GEN_NONE;
00313   }
00314   
00315   forceinline int
00316   ConstantView::glbMin(const Delta*) const {
00317     GECODE_NEVER;
00318     return 0;
00319   }
00320 
00321   forceinline int
00322   ConstantView::glbMax(const Delta*) const {
00323     GECODE_NEVER;
00324     return 0;
00325   }
00326 
00327   forceinline bool
00328   ConstantView::glbAny(const Delta*) const {
00329     GECODE_NEVER;
00330     return false;
00331   }
00332 
00333   forceinline int
00334   ConstantView::lubMin(const Delta*) const {
00335     GECODE_NEVER;
00336     return 0;
00337   }
00338 
00339   forceinline int
00340   ConstantView::lubMax(const Delta*) const {
00341     GECODE_NEVER;
00342     return 0;
00343   }
00344 
00345   forceinline bool
00346   ConstantView::lubAny(const Delta*) const {
00347     GECODE_NEVER;
00348     return false;
00349   }
00350 
00351   forceinline
00352   EmptyView::EmptyView(void) {}
00353 
00354   forceinline
00355   EmptyView::EmptyView(Space*, const Reflection::VarMap&,
00356                        Reflection::Arg*) {}
00357 
00358 
00359   forceinline bool
00360   EmptyView::assigned(void) const { return true; }
00361 
00362   forceinline unsigned int
00363   EmptyView::glbSize(void) const { return 0; }
00364 
00365   forceinline unsigned int
00366   EmptyView::lubSize(void) const { return 0; }
00367 
00368   forceinline unsigned int
00369   EmptyView::unknownSize(void) const { return 0; }
00370 
00371   forceinline bool
00372   EmptyView::contains(int) const { return false; }
00373 
00374   forceinline bool
00375   EmptyView::notContains(int) const { return true; }
00376 
00377   forceinline unsigned int
00378   EmptyView::cardMin(void) const { return 0; }
00379 
00380   forceinline unsigned int
00381   EmptyView::cardMax(void) const { return 0; }
00382 
00383   forceinline int
00384   EmptyView::lubMin(void) const { return 0; }
00385 
00386   forceinline int
00387   EmptyView::lubMax(void) const { return 0; }
00388 
00389   forceinline int
00390   EmptyView::glbMin(void) const { return 0; }
00391 
00392   forceinline int
00393   EmptyView::glbMax(void) const { return 0; }
00394 
00395   forceinline ModEvent
00396   EmptyView::cardMin(Space*,unsigned int c) {
00397     return c==0 ? ME_SET_NONE : ME_SET_FAILED;
00398   }
00399 
00400   forceinline ModEvent
00401   EmptyView::cardMax(Space*,unsigned int) {
00402     return ME_SET_NONE;
00403   }
00404 
00405 
00406   forceinline ModEvent
00407   EmptyView::include(Space*,int) {
00408     return ME_SET_FAILED;
00409   }
00410 
00411   forceinline ModEvent
00412   EmptyView::exclude(Space*,int) { return ME_SET_NONE; }
00413 
00414   forceinline ModEvent
00415   EmptyView::intersect(Space*,int) { return ME_SET_NONE; }
00416 
00417   forceinline ModEvent
00418   EmptyView::intersect(Space*,int,int) { return ME_SET_NONE; }
00419 
00420   forceinline ModEvent
00421   EmptyView::include(Space*,int,int) {
00422     return ME_SET_FAILED; }
00423 
00424   forceinline ModEvent
00425   EmptyView::exclude(Space*,int,int) { return ME_SET_NONE; }
00426 
00427   template <class I> ModEvent
00428   EmptyView::excludeI(Space*,I&) { return ME_SET_NONE; }
00429 
00430   template <class I> ModEvent
00431   EmptyView::includeI(Space*,I& i) {
00432     return i() ? ME_SET_FAILED : ME_SET_NONE;
00433   }
00434 
00435   template <class I> ModEvent
00436   EmptyView::intersectI(Space*,I&) {
00437     return ME_SET_NONE;
00438   }
00439 
00440   forceinline void
00441   EmptyView::schedule(Space* home, Propagator* p, ModEvent me) {
00442     return SetView::schedule(home,p,me);
00443   }
00444   forceinline ModEvent
00445   EmptyView::me(ModEventDelta) {
00446     return ME_SET_NONE;
00447   }
00448   forceinline ModEventDelta
00449   EmptyView::med(ModEvent me) {
00450     return SetVarImp::med(me);
00451   }
00452 
00453   forceinline void
00454   EmptyView::subscribe(Space* home, Propagator* p, PropCond,bool) {
00455     schedule(home,p,ME_SET_VAL);    
00456   }
00457   forceinline void
00458   EmptyView::cancel(Space*,Propagator*,PropCond) {}
00459   forceinline void
00460   EmptyView::subscribe(Space*, Advisor*) {}
00461   forceinline void
00462   EmptyView::cancel(Space*,Advisor*) {}
00463 
00464 
00465   forceinline void
00466   EmptyView::update(Space*, bool, EmptyView&) {}
00467 
00468   forceinline Reflection::Arg*
00469   EmptyView::spec(const Space*, Reflection::VarMap&) const {
00470     return NULL;
00471   }
00472 
00473   inline Support::Symbol
00474   EmptyView::type(void) {
00475     return Support::Symbol("Gecode::Set::EmptyView");
00476   }
00477 
00478   /*
00479    * Delta information for advisors
00480    *
00481    */
00482 
00483   forceinline ModEvent
00484   EmptyView::modevent(const Delta*) {
00485     GECODE_NEVER;
00486     return ME_GEN_NONE;
00487   }
00488   
00489   forceinline int
00490   EmptyView::glbMin(const Delta*) const {
00491     GECODE_NEVER;
00492     return 0;
00493   }
00494 
00495   forceinline int
00496   EmptyView::glbMax(const Delta*) const {
00497     GECODE_NEVER;
00498     return 0;
00499   }
00500 
00501   forceinline bool
00502   EmptyView::glbAny(const Delta*) const {
00503     GECODE_NEVER;
00504     return false;
00505   }
00506 
00507   forceinline int
00508   EmptyView::lubMin(const Delta*) const {
00509     GECODE_NEVER;
00510     return 0;
00511   }
00512 
00513   forceinline int
00514   EmptyView::lubMax(const Delta*) const {
00515     GECODE_NEVER;
00516     return 0;
00517   }
00518 
00519   forceinline bool
00520   EmptyView::lubAny(const Delta*) const {
00521     GECODE_NEVER;
00522     return false;
00523   }
00524 
00525   // Constant universe variable
00526 
00527   forceinline
00528   UniverseView::UniverseView(void) {}
00529 
00530   forceinline
00531   UniverseView::UniverseView(Space*,
00532                              const Reflection::VarMap&,
00533                              Reflection::Arg*) {}
00534 
00535   forceinline bool
00536   UniverseView::assigned(void) const { return true; }
00537 
00538   forceinline unsigned int
00539   UniverseView::glbSize(void) const { return Set::Limits::card; }
00540 
00541   forceinline unsigned int
00542   UniverseView::lubSize(void) const { return Set::Limits::card; }
00543 
00544   forceinline unsigned int
00545   UniverseView::unknownSize(void) const { return 0; }
00546 
00547   forceinline bool
00548   UniverseView::contains(int) const { return true; }
00549 
00550   forceinline bool
00551   UniverseView::notContains(int) const { return false; }
00552 
00553   forceinline unsigned int
00554   UniverseView::cardMin(void) const { return Set::Limits::card; }
00555 
00556   forceinline unsigned int
00557   UniverseView::cardMax(void) const { return Limits::card; }
00558 
00559   forceinline int
00560   UniverseView::lubMin(void) const { return Limits::card; }
00561 
00562   forceinline int
00563   UniverseView::lubMax(void) const { return Limits::card; }
00564 
00565   forceinline int
00566   UniverseView::glbMin(void) const { return Limits::card; }
00567 
00568   forceinline int
00569   UniverseView::glbMax(void) const { return Limits::card; }
00570 
00571   forceinline ModEvent
00572   UniverseView::cardMin(Space*,unsigned int c) {
00573     return c>Limits::card ? ME_SET_FAILED : ME_SET_NONE;
00574   }
00575 
00576   forceinline ModEvent
00577   UniverseView::cardMax(Space*,unsigned int c) {
00578     return c>=Limits::card ? ME_SET_NONE : ME_SET_FAILED;
00579   }
00580 
00581 
00582   forceinline ModEvent
00583   UniverseView::include(Space*,int) {
00584     return ME_SET_NONE;
00585   }
00586 
00587   forceinline ModEvent
00588   UniverseView::exclude(Space*,int) { return ME_SET_FAILED; }
00589 
00590   forceinline ModEvent
00591   UniverseView::intersect(Space*,int) { return ME_SET_FAILED; }
00592 
00593   forceinline ModEvent
00594   UniverseView::include(Space*,int,int) { return ME_SET_NONE; }
00595 
00596   forceinline ModEvent
00597   UniverseView::exclude(Space*,int,int) { return ME_SET_FAILED; }
00598 
00599   template <class I> ModEvent
00600   UniverseView::excludeI(Space*,I& i) {
00601     return i() ? ME_SET_FAILED : ME_SET_NONE;
00602   }
00603 
00604   template <class I> forceinline ModEvent
00605   UniverseView::includeI(Space*,I&) { return ME_SET_NONE; }
00606 
00607   forceinline ModEvent
00608   UniverseView::intersect(Space*,int i,int j) {
00609     return (i>Limits::min ||
00610             j<Limits::max) ? ME_SET_FAILED : ME_SET_NONE;
00611   }
00612 
00613   template <class I> forceinline ModEvent
00614   UniverseView::intersectI(Space*,I& i) {
00615     return (i() &&
00616             (i.min()>Limits::min ||
00617              i.max()<Limits::max) ) ?
00618       ME_SET_FAILED : ME_SET_NONE;
00619   }
00620 
00621   forceinline void
00622   UniverseView::schedule(Space* home, Propagator* p, ModEvent me) {
00623     return SetView::schedule(home,p,me);
00624   }
00625   forceinline ModEvent
00626   UniverseView::me(ModEventDelta) {
00627     return ME_SET_NONE;
00628   }
00629   forceinline ModEventDelta
00630   UniverseView::med(ModEvent me) {
00631     return SetVarImp::med(me);
00632   }
00633   forceinline void
00634   UniverseView::subscribe(Space* home, Propagator* p, PropCond,bool) {
00635     schedule(home,p,ME_SET_VAL);    
00636   }
00637   forceinline void
00638   UniverseView::cancel(Space*,Propagator*,PropCond) {}
00639 
00640   forceinline void
00641   UniverseView::subscribe(Space*,Advisor*) {}
00642   forceinline void
00643   UniverseView::cancel(Space*,Advisor*) {}
00644 
00645 
00646   forceinline void
00647   UniverseView::update(Space*, bool, UniverseView&) {}
00648 
00649   forceinline Reflection::Arg*
00650   UniverseView::spec(const Space*, Reflection::VarMap&) const {
00651     return NULL;
00652   }
00653 
00654   inline Support::Symbol
00655   UniverseView::type(void) {
00656     return Support::Symbol("Gecode::Set::UniverseView");
00657   }
00658 
00659   /*
00660    * Delta information for advisors
00661    *
00662    */
00663 
00664   forceinline ModEvent
00665   UniverseView::modevent(const Delta*) {
00666     GECODE_NEVER;
00667     return ME_GEN_NONE;
00668   }
00669   
00670   forceinline int
00671   UniverseView::glbMin(const Delta*) const {
00672     GECODE_NEVER;
00673     return 0;
00674   }
00675 
00676   forceinline int
00677   UniverseView::glbMax(const Delta*) const {
00678     GECODE_NEVER;
00679     return 0;
00680   }
00681 
00682   forceinline bool
00683   UniverseView::glbAny(const Delta*) const {
00684     GECODE_NEVER;
00685     return false;
00686   }
00687 
00688   forceinline int
00689   UniverseView::lubMin(const Delta*) const {
00690     GECODE_NEVER;
00691     return 0;
00692   }
00693 
00694   forceinline int
00695   UniverseView::lubMax(const Delta*) const {
00696     GECODE_NEVER;
00697     return 0;
00698   }
00699 
00700   forceinline bool
00701   UniverseView::lubAny(const Delta*) const {
00702     GECODE_NEVER;
00703     return false;
00704   }
00705 
00706   /*
00707    * Iterators
00708    *
00709    */
00710 
00715   template <>
00716   class LubRanges<EmptyView> : public Iter::Ranges::Empty {
00717   public:
00719 
00720 
00721     LubRanges(void) {}
00723     LubRanges(const EmptyView& x) { (void)x; }
00725     void init(const EmptyView& x) { (void)x; }
00727   };
00728 
00733   template <>
00734   class GlbRanges<EmptyView> : public Iter::Ranges::Empty {
00735   public:
00737 
00738 
00739     GlbRanges(void) {}
00741     GlbRanges(const EmptyView& x) { (void)x; }
00743     void init(const EmptyView& x) { (void)x; }
00745   };
00746 
00751   template <>
00752   class LubRanges<UniverseView> : public Iter::Ranges::Singleton {
00753   public:
00755 
00756 
00757     LubRanges(void)
00758       : Iter::Ranges::Singleton(Limits::min,
00759                                 Limits::max) {}
00761     LubRanges(const UniverseView& x)
00762       : Iter::Ranges::Singleton(Limits::min,
00763                                 Limits::max) {
00764         (void)x;
00765       }
00767     void init(const UniverseView& x) { (void)x; }
00769   };
00770 
00775   template <>
00776   class GlbRanges<UniverseView> : public Iter::Ranges::Singleton {
00777   public:
00779 
00780 
00781     GlbRanges(void)
00782       : Iter::Ranges::Singleton(Limits::min,
00783                                 Limits::max) {}
00785     GlbRanges(const UniverseView& x)
00786       : Iter::Ranges::Singleton(Limits::min,
00787                                 Limits::max) {
00788       (void)x;
00789     }
00791     void init(const UniverseView& x) { (void)x; }
00793   };
00794 
00795 
00800   template <>
00801   class LubRanges<ConstantView> {
00802   private:
00803     ArrayRanges ar;
00804   public:
00806 
00807 
00808     LubRanges(void) {}
00810     LubRanges(const ConstantView& x) : ar(x.ranges,x.size) {}
00812     void init(const ConstantView& x) {
00813       ar.init(x.ranges,x.size);
00814     }
00816 
00818 
00819 
00820     bool operator()(void) const { return ar(); }
00822     void operator++(void) { ++ar; }
00824 
00826 
00827 
00828     int min(void) const { return ar.min(); }
00830     int max(void) const { return ar.max(); }
00832     unsigned int width(void) const { return ar.width(); }
00834   };
00835 
00840   template <>
00841   class GlbRanges<ConstantView> : public LubRanges<ConstantView> {
00842   public:
00844 
00845 
00846     GlbRanges(void) {}
00848     GlbRanges(const ConstantView& x) : LubRanges<ConstantView>(x) {}
00850     void init(const ConstantView& x) {
00851       LubRanges<ConstantView>::init(x);
00852     }
00854   };
00855 }
00856 
00857 
00858   /*
00859    * Testing
00860    *
00861    */
00862   forceinline bool
00863   same(const Set::ConstantView& x, const Set::ConstantView& y) {
00864     if ((x.size != y.size) || (x.domSize != y.domSize))
00865       return false;
00866     for (int i=x.size; i--; )
00867       if (x.ranges[2*i]   != y.ranges[2*i] ||
00868           x.ranges[2*i+1] != y.ranges[2*i+1])
00869         return false;
00870     return true;
00871   }
00872   forceinline bool
00873   before(const Set::ConstantView& x, const Set::ConstantView& y) {
00874     if (x.size < y.size)
00875       return true;
00876     if (x.domSize < y.domSize)
00877       return true;
00878     for (int i=x.size; i--; )
00879       if (x.ranges[2*i]   < y.ranges[2*i] ||
00880           x.ranges[2*i+1] < y.ranges[2*i+1])
00881         return true;
00882     return false;
00883   }
00884 
00885 
00886   forceinline bool
00887   same(const Set::EmptyView&, const Set::EmptyView&) {
00888     return true;
00889   }
00890   forceinline bool
00891   before(const Set::EmptyView&, const Set::EmptyView&) {
00892     return false;
00893   }
00894 
00895   forceinline bool
00896   same(const Set::UniverseView&, const Set::UniverseView&) {
00897     return true;
00898   }
00899   forceinline bool
00900   before(const Set::UniverseView&, const Set::UniverseView&) {
00901     return false;
00902   }
00903 
00904 }
00905 
00906 // STATISTICS: set-var
00907