64 unsigned int size = 0;
66 d[n].min = i.min(); d[n].max = i.max(); size += i.width();
70 IntSet::IntSetObject* o = IntSet::IntSetObject::allocate(n);
71 for (
int j=0; j<n; j++)
116 int n =
static_cast<int>(r.size());
119 Range* dr = reg.
alloc<Range>(n);
120 for (
int i=0; i<n; i++)
121 dr[i].
min=dr[i].
max=r[
static_cast<unsigned int>(i)];
134 int n =
static_cast<int>(r.size());
137 Range* dr = reg.
alloc<Range>(n);
139 for (
int i=0; i<n; i++)
140 if (r[
static_cast<unsigned int>(i)].first <=
141 r[
static_cast<unsigned int>(i)].second) {
142 dr[j].min=r[
static_cast<unsigned int>(i)].first;
143 dr[j].max=r[
static_cast<unsigned int>(i)].second;
157 assert(
object() !=
nullptr);
158 return static_cast<IntSetObject*
>(
object())->r[i].
min;
163 assert(
object() !=
nullptr);
164 return static_cast<IntSetObject*
>(
object())->r[i].
max;
167 forceinline
unsigned int
169 assert(
object() !=
nullptr);
170 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
171 return static_cast<unsigned int>(o->r[i].max) -
172 static_cast<unsigned int>(o->r[i].min) + 1U;
177 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
178 return (o ==
nullptr) ? 0 : o->n;
183 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
184 if ((o ==
nullptr) || (n < o->r[0].
min) || (n > o->r[o->n-1].max))
192 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
198 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
202 forceinline
unsigned int
204 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
205 return (o ==
nullptr) ? 0U : o->size;
208 forceinline
unsigned int
210 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
211 return (o ==
nullptr) ? 0U :
212 static_cast<unsigned int>(
max()) -
static_cast<unsigned int>(
min()) + 1U;
217 IntSetObject* o1 =
static_cast<IntSetObject*
>(
object());
218 IntSetObject* o2 =
static_cast<IntSetObject*
>(s.
object());
221 if ((o1 ==
nullptr) || (o2 ==
nullptr))
223 if ((o1->size != o2->size) || (o1->n != o2->n))
225 return o1->equal(*o2);
230 return !(*
this == s);
246 i = &
static_cast<IntSet::IntSetObject*
>(s.
object())->r[0]; e = i+n;
272 forceinline
unsigned int
274 return static_cast<unsigned int>(i->max) -
275 static_cast<unsigned int>(i->min) + 1U;
297 template<
class Char,
class Traits>
298 std::basic_ostream<Char,Traits>&
300 std::basic_ostringstream<Char,Traits> s;
301 s.copyfmt(os); s.width(0);
303 for (
int i = 0; i < is.
ranges(); ) {
315 return os << s.str();
static void init(IntSet &s, const IntSet &i)
Integer set initialization.
static void init(IntSet &s, I &i)
Initialize s with iterator i.
Range iterator for integer sets.
unsigned int width(void) const
Return width of range (distance between minimum and maximum).
bool operator()(void) const
Test whether iterator is still at a range or done.
int max(void) const
Return largest value of range.
void operator++(void)
Move iterator to next range (if possible).
void init(const IntSet &s)
Initialize with ranges for set s.
int min(void) const
Return smallest value of range.
IntSetRanges(void)
Default constructor.
void init(const IntSet &s)
Initialize with values for s.
IntSetValues(void)
Default constructor.
int min(void) const
Return minimum of entire set.
unsigned int width(void) const
Return width of set (distance between maximum and minimum).
int min(int i) const
Return minimum of range at position i.
bool in(int n) const
Return whether n is included in the set.
int max(int i) const
Return maximum of range at position i.
int max(void) const
Return maximum of entire set.
int ranges(void) const
Return number of ranges of the specification.
bool operator==(const IntSet &s) const
Return whether s is equal.
unsigned int size(void) const
Return size (cardinality) of set.
IntSet(void)
Initialize as empty set.
bool operator!=(const IntSet &s) const
Return whether s is not equal.
void init(I &i)
Initialize with values from range iterator i.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
SharedHandle::Object * object(void) const
Access to the shared object.
Array with arbitrary number of elements.
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
Gecode toplevel namespace
Archive & operator<<(Archive &e, FloatNumBranch nl)
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .