63 unsigned int size = 0;
65 d[
n].min = i.min(); d[
n].max = i.max(); size += i.width();
69 IntSet::IntSetObject* o = IntSet::IntSetObject::allocate(n);
116 assert(
object() != NULL);
117 return static_cast<IntSetObject*
>(
object())->
r[i].
min;
122 assert(
object() != NULL);
123 return static_cast<IntSetObject*
>(
object())->
r[i].
max;
128 assert(
object() != NULL);
129 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
130 return static_cast<unsigned int>(o->r[
i].max-o->r[
i].min)+1;
135 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
136 return (o == NULL) ? 0 : o->n;
141 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
142 if ((o == NULL) || (n < o->r[0].min) || (n > o->r[o->n-1].max))
150 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
156 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
162 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
163 return (o == NULL) ? 0 : o->size;
168 return static_cast<unsigned int>(
max()-
min()+1);
184 i = &
static_cast<IntSet::IntSetObject*
>(s.
object())->
r[0]; e = i+
n;
212 return static_cast<unsigned int>(i->max - i->min) + 1;
234 template<
class Char,
class Traits>
235 std::basic_ostream<Char,Traits>&
236 operator <<(std::basic_ostream<Char,Traits>& os,
const IntSet& is) {
237 std::basic_ostringstream<Char,Traits> s;
238 s.copyfmt(os); s.
width(0);
240 for (
int i = 0;
i < is.ranges(); ) {
246 s << min <<
".." <<
max;
252 return os << s.str();
void init(I &i)
Initialize with values from range iterator i.
Range iterator for integer sets.
IntSetValues(void)
Default constructor.
bool in(int n) const
Return whether n is included in the set.
void operator++(void)
Move iterator to next range (if possible)
int min(void) const
Return minimum of entire set.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void init(const IntSet &s)
Initialize with values for s.
bool operator()(void) const
Test whether iterator is still at a range or done.
Array with arbitrary number of elements.
const int max
Largest allowed integer value.
unsigned int width(void) const
Return width of set (distance between maximum and minimum)
void init(const IntSet &s)
Initialize with ranges for set s.
const int min
Smallest allowed integer value.
static void init(IntSet &s, const IntSet &i)
Heap heap
The single global heap.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
static void init(IntSet &s, I &i)
Initialize s with iterator i.
int ranges(void) const
Return number of ranges of the specification.
unsigned int size(I &i)
Size of all ranges of range iterator i.
unsigned int width(int i) const
Return width of range at position i.
int min(void) const
Return smallest value of range.
Integer set initialization.
unsigned int size(void) const
Return size (cardinality) of set.
IntSet(void)
Initialize as empty set.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
int max(void) const
Return largest value of range.
SharedHandle::Object * object(void) const
Access to the shared object.
Gecode toplevel namespace
int max(void) const
Return maximum of entire set.
IntSetRanges(void)
Default constructor.