60 unsigned int size = 0;
62 d[n].
min = i.min(); d[n].
max = i.max(); size += i.width();
66 IntSet::IntSetObject* o = IntSet::IntSetObject::allocate(n);
67 for (
int j=0; j<n; j++)
112 int n =
static_cast<int>(
r.size());
115 Range* dr = reg.
alloc<Range>(n);
116 for (
int i=0; i<n; i++)
117 dr[i].
min=dr[i].
max=
r[
static_cast<unsigned int>(i)];
130 int n =
static_cast<int>(
r.size());
133 Range* dr = reg.
alloc<Range>(n);
135 for (
int i=0; i<n; i++)
136 if (
r[
static_cast<unsigned int>(i)].first <=
137 r[
static_cast<unsigned int>(i)].second) {
138 dr[j].min=
r[
static_cast<unsigned int>(i)].first;
139 dr[j].max=
r[
static_cast<unsigned int>(i)].second;
153 assert(
object() != NULL);
154 return static_cast<IntSetObject*
>(
object())->
r[i].
min;
159 assert(
object() != NULL);
160 return static_cast<IntSetObject*
>(
object())->
r[i].
max;
165 assert(
object() != NULL);
166 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
167 return static_cast<unsigned int>(o->r[i].max-o->r[i].min)+1;
172 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
173 return (o == NULL) ? 0 : o->n;
178 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
179 if ((o == NULL) || (n < o->
r[0].
min) || (n > o->r[o->n-1].max))
187 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
193 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
199 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
200 return (o == NULL) ? 0U : o->size;
205 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
206 return (o == NULL) ? 0U :
static_cast<unsigned int>(
max()-
min()+1);
211 IntSetObject* o1 =
static_cast<IntSetObject*
>(
object());
212 IntSetObject* o2 =
static_cast<IntSetObject*
>(s.
object());
215 if ((o1 ==
nullptr) || (o2 ==
nullptr))
217 if ((o1->size != o2->size) || (o1->n != o2->n))
219 return o1->equal(*o2);
224 return !(*
this == s);
240 i = &
static_cast<IntSet::IntSetObject*
>(s.
object())->r[0]; e = i+n;
268 return static_cast<unsigned int>(i->max - i->min) + 1;
290 template<
class Char,
class Traits>
291 std::basic_ostream<Char,Traits>&
293 std::basic_ostringstream<Char,Traits> s;
294 s.copyfmt(os); s.width(0);
296 for (
int i = 0; i < is.
ranges(); ) {
308 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
Post propagator for SetVar SetOpType SetVar SetRelType r
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 .