/* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2004 * * Last modified: * $Date: 2006-08-04 16:05:50 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $ * $Revision: 3515 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * See the file "LICENSE" for information on usage and * redistribution of this file, and for a * DISCLAIMER OF ALL WARRANTIES. * */ namespace Gecode { namespace Iter { namespace Ranges { /** * \brief Range iterator for pointwise offset (by some constant) * * Requires \code #include "gecode/iter.hh" \endcode * \ingroup FuncIterRanges */ template class Offset { protected: /// Input range I i; /// Offset for ranges int c; public: /// \name Constructors and initialization //@{ /// Default constructor Offset(void); /// Initialize with ranges from \a i and offset \a c Offset(I& i, int c); /// Initialize with ranges from \a i and offset \a c void init(I& i, int c); //@} /// \name Iteration control //@{ /// Test whether iterator is still at a range or done bool operator()(void) const; /// Move iterator to next range (if possible) void operator++(void); //@} /// \name Range access //@{ /// Return smallest value of range int min(void) const; /// Return largest value of range int max(void) const; /// Return width of range (distance between minimum and maximum) unsigned int width(void) const; //@} }; template forceinline Offset::Offset(void) {} template inline void Offset::init(I& i0, int c0) { i = i0; c = c0; } template inline Offset::Offset(I& i0, int c0) : i(i0), c(c0) {} template forceinline void Offset::operator++(void) { ++i; } template forceinline bool Offset::operator()(void) const { return i(); } template forceinline int Offset::min(void) const { return i.min()+c; } template forceinline int Offset::max(void) const { return i.max()+c; } template forceinline unsigned int Offset::width(void) const { return i.width(); } }}} // STATISTICS: iter-any