Generated on Wed Nov 1 15:04:41 2006 for Gecode by doxygen 1.4.5

ranges-add.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2005
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-04 16:05:50 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3515 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 namespace Gecode { namespace Iter { namespace Ranges {
00023 
00030   template <class I>
00031   class AddRange : public MinMax {
00032   protected:
00034     I i;
00036     int r_min;
00038     int r_max;
00039   public:
00041 
00042 
00043     AddRange(void);
00045     AddRange(I& i, int min, int max);
00047     void init(I& i, int min, int max);
00049 
00051 
00052 
00053     void operator++(void);
00055   };
00056 
00057 
00064   template <class I>
00065   class SubRange : public AddRange<I> {
00066   public:
00068 
00069 
00070     SubRange(void);
00072     SubRange(I& i, int min, int max);
00074     void init(I& i, int min, int max);
00076   };
00077 
00078   template <class I>
00079   forceinline
00080   AddRange<I>::AddRange(void) {}
00081 
00082   template <class I>
00083   forceinline void
00084   AddRange<I>::operator++(void) {
00085     if (i()) {
00086       mi = r_min + i.min();
00087       ma = r_max + i.max();
00088       ++i;
00089       while (i() && (ma+1 >= r_min+i.min())) {
00090         ma = r_max + i.max(); ++i;
00091       }
00092     } else {
00093       finish();
00094     }
00095   }
00096 
00097   template <class I>
00098   forceinline
00099   AddRange<I>::AddRange(I& i0, int r_min0, int r_max0)
00100     : i(i0), r_min(r_min0), r_max(r_max0) {
00101     operator++();
00102   }
00103 
00104   template <class I>
00105   forceinline void
00106   AddRange<I>::init(I& i0, int r_min0, int r_max0) {
00107     i = i0; r_min = r_min0; r_max = r_max0;
00108     operator++();
00109   }
00110 
00111 
00112   template <class I>
00113   forceinline
00114   SubRange<I>::SubRange(void) {}
00115 
00116   template <class I>
00117   forceinline
00118   SubRange<I>::SubRange(I& i, int r_min, int r_max)
00119     : AddRange<I>(i,-r_max,-r_min) {}
00120 
00121   template <class I>
00122   forceinline void
00123   SubRange<I>::init(I& i, int r_min, int r_max) {
00124     AddRange<I>::init(i,-r_max,-r_min);
00125   }
00126 
00127 }}}
00128 
00129 // STATISTICS: iter-any
00130