Generated on Wed Jan 4 17:49:12 2006 for Gecode by doxygen 1.4.6

ranges-compl.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2004
00008  *     Christian Schulte, 2005
00009  *
00010  *  Last modified:
00011  *     $Date: 2005-07-29 21:55:06 +0200 (Fri, 29 Jul 2005) $ by $Author: schulte $
00012  *     $Revision: 2085 $
00013  *
00014  *  This file is part of Gecode, the generic constraint
00015  *  development environment:
00016  *     http://www.gecode.org
00017  *
00018  *  See the file "LICENSE" for information on usage and
00019  *  redistribution of this file, and for a
00020  *     DISCLAIMER OF ALL WARRANTIES.
00021  *
00022  */
00023 
00024 namespace Gecode { namespace Iter { namespace Ranges {
00025 
00036   template <int UMIN, int UMAX, class I>
00037   class Compl : public MinMax {
00038   protected:
00040     I i;
00042     void start(void);
00043   public:
00045 
00046 
00047     Compl(void);
00049     Compl(I& i);
00051     void init(I& i);
00053 
00055 
00056 
00057     void operator++(void);
00059   };
00060 
00061 
00062   template <int UMIN, int UMAX, class I>
00063   inline void
00064   Compl<UMIN,UMAX,I>::start(void) {
00065     if (i()) {
00066       assert((i.min() >= UMIN) && (i.max() <= UMAX));
00067       if (i.min() > UMIN) {
00068         mi = UMIN;
00069         ma = i.min()-1;
00070       } else if (i.max() < UMAX) {
00071         mi = i.max()+1;
00072         ++i;
00073         ma = i() ? (i.min()-1) : UMAX;
00074       } else {
00075         finish();
00076       }
00077     } else {
00078       mi = UMIN;
00079       ma = UMAX;
00080     }
00081   }
00082 
00083   template <int UMIN, int UMAX, class I>
00084   forceinline
00085   Compl<UMIN,UMAX,I>::Compl(void) {}
00086 
00087   template <int UMIN, int UMAX, class I>
00088   forceinline
00089   Compl<UMIN,UMAX,I>::Compl(I& i0) : i(i0) {
00090     start();
00091   }
00092 
00093   template <int UMIN, int UMAX, class I>
00094   forceinline void
00095   Compl<UMIN,UMAX,I>::init(I& i0) {
00096     i=i0; start();
00097   }
00098 
00099   template <int UMIN, int UMAX, class I>
00100   forceinline void
00101   Compl<UMIN,UMAX,I>::operator++(void) {
00102     assert(!i() || (i.max() <= UMAX));
00103     if (i() && (i.max() < UMAX)) {
00104       mi = i.max()+1;
00105       ++i;
00106       ma = i() ? (i.min()-1) : UMAX;
00107     } else {
00108       finish();
00109     }
00110   }
00111 
00112 }}}
00113 
00114 // STATISTICS: iter-any
00115