3
* Christian Schulte <schulte@gecode.org>
6
* Christian Schulte, 2004
9
* $Date: 2005-07-29 21:55:06 +0200 (Fri, 29 Jul 2005) $ by $Author: schulte $
12
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
16
* See the file "LICENSE" for information on usage and
17
* redistribution of this file, and for a
18
* DISCLAIMER OF ALL WARRANTIES.
22
#include "support/shared-array.hh"
24
namespace Gecode { namespace Iter { namespace Ranges {
27
* \brief %Range iterator cache
29
* Allows to iterate the ranges as defined by the input iterator
30
* several times provided the Cache is %reset by the reset member
33
* Requires \code #include "iter.hh" \endcode
34
* \ingroup FuncIterRanges
39
/// %Ranges stored in cache
45
Support::SharedArray<Range> r;
48
/// Number of ranges in cache
51
/// \name Constructors and initialization
53
/// Default constructor
55
/// Initialize with ranges from \a i
57
/// Initialize with ranges from \a i
61
/// \name Iteration control
63
/// Test whether iterator is still at a range or done
64
bool operator()(void) const;
65
/// Move iterator to next range (if possible)
66
void operator++(void);
67
/// Reset iterator to start from beginning
71
/// \name %Range access
73
/// Return smallest value of range
75
/// Return largest value of range
77
/// Return width of range (distance between minimum and maximum)
78
unsigned int width(void) const;
90
Cache<I>::init(I& i) {
94
r[j].min = i.min(); r[j].max = i.max();
103
Cache<I>::Cache(I& i) : r(8) {
109
Cache<I>::operator++(void) {
114
Cache<I>::operator()(void) const {
120
Cache<I>::reset(void) {
126
Cache<I>::min(void) const {
131
Cache<I>::max(void) const {
135
forceinline unsigned int
136
Cache<I>::width(void) const {
137
return r[c].max-r[c].min+1;
142
// STATISTICS: iter-any