59 unsigned int size = 0;
61 d[
n].min = i.min(); d[
n].max = i.max(); size += i.width();
65 IntSet::IntSetObject* o = IntSet::IntSetObject::allocate(n);
112 assert(
object() != NULL);
113 return static_cast<IntSetObject*
>(
object())->
r[i].
min;
118 assert(
object() != NULL);
119 return static_cast<IntSetObject*
>(
object())->
r[i].
max;
124 assert(
object() != NULL);
125 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
126 return static_cast<unsigned int>(o->r[
i].max-o->r[
i].min)+1;
131 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
132 return (o == NULL) ? 0 : o->n;
137 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
138 if ((o == NULL) || (n < o->r[0].min) || (n > o->r[o->n-1].max))
146 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
152 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
158 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
159 return (o == NULL) ? 0 : o->size;
164 return static_cast<unsigned int>(
max()-
min()+1);
180 i = &
static_cast<IntSet::IntSetObject*
>(s.
object())->
r[0]; e =
i+
n;
208 return static_cast<unsigned int>(
i->max -
i->min) + 1;
230 template<
class Char,
class Traits>
231 std::basic_ostream<Char,Traits>&
232 operator <<(std::basic_ostream<Char,Traits>& os,
const IntSet& is) {
233 std::basic_ostringstream<Char,Traits> s;
234 s.copyfmt(os); s.
width(0);
236 for (
int i = 0;
i < is.ranges(); ) {
242 s << min <<
".." <<
max;
248 return os << s.str();
int max(void) const
Return maximum of entire set.
void init(I &i)
Initialize with values from range iterator i.
Range iterator for integer sets.
IntSetValues(void)
Default constructor.
void operator++(void)
Move iterator to next range (if possible)
unsigned int width(int i) const
Return width of range at position i.
void init(const IntSet &s)
Initialize with values for s.
Array with arbitrary number of elements.
bool operator()(void) const
Test whether iterator is still at a range or done.
const int max
Largest allowed integer value.
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)
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.
SharedHandle::Object * object(void) const
Access to the shared object.
unsigned int size(void) const
Return size (cardinality) of set.
Integer set initialization.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
unsigned int width(void) const
Return width of set (distance between maximum and minimum)
IntSet(void)
Initialize as empty set.
Post propagator for SetVar SetOpType SetVar SetRelType r
int min(void) const
Return smallest value of range.
int min(void) const
Return minimum of entire set.
Heap heap
The single global heap.
int ranges(void) const
Return number of ranges of the specification.
int max(void) const
Return largest value of range.
Gecode toplevel namespace
bool in(int n) const
Return whether n is included in the set.
IntSetRanges(void)
Default constructor.