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++)
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[
i].first <=
r[
i].second) {
137 dr[j].min=
r[
i].first; dr[j].max=
r[
i].second; j++;
150 assert(
object() != NULL);
151 return static_cast<IntSetObject*
>(
object())->
r[i].
min;
156 assert(
object() != NULL);
157 return static_cast<IntSetObject*
>(
object())->
r[i].
max;
162 assert(
object() != NULL);
163 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
164 return static_cast<unsigned int>(o->r[
i].max-o->r[
i].min)+1;
169 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
170 return (o == NULL) ? 0 : o->n;
175 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
176 if ((o == NULL) || (n < o->r[0].min) || (n > o->r[o->n-1].max))
184 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
190 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
196 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
197 return (o == NULL) ? 0U : o->size;
202 IntSetObject* o =
static_cast<IntSetObject*
>(
object());
203 return (o == NULL) ? 0U :
static_cast<unsigned int>(
max()-
min()+1);
208 IntSetObject* o1 =
static_cast<IntSetObject*
>(
object());
209 IntSetObject* o2 =
static_cast<IntSetObject*
>(s.
object());
212 if ((o1 ==
nullptr) || (o2 ==
nullptr))
214 if ((o1->size != o2->size) || (o1->n != o2->n))
216 return o1->equal(*o2);
221 return !(*
this == s);
237 i = &
static_cast<IntSet::IntSetObject*
>(s.
object())->
r[0]; e =
i+
n;
265 return static_cast<unsigned int>(
i->max -
i->min) + 1;
287 template<
class Char,
class Traits>
288 std::basic_ostream<Char,Traits>&
289 operator <<(std::basic_ostream<Char,Traits>& os,
const IntSet& is) {
290 std::basic_ostringstream<Char,Traits> s;
291 s.copyfmt(os); s.
width(0);
293 for (
int i = 0;
i < is.ranges(); ) {
299 s << min <<
".." <<
max;
305 return os << s.str();
bool operator==(const IntSet &s) const
Return whether s is equal.
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)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
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)
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})
static void init(IntSet &s, I &i)
Initialize s with iterator i.
SharedHandle::Object * object(void) const
Access to the shared object.
bool operator!=(const IntSet &s) const
Return whether s is not equal.
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.
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.