42 namespace Gecode {
namespace Set {
52 for (
int i = n;
i--; ) {
66 assert(
fst() != NULL);
72 if (c->
max() >= mi-1){
73 if (c->
min() > ma+1) {
93 d._glbMin = c->
max()+1;
96 assert(c->
max()+1>=mi);
98 d._glbMax = c->
min()-1;
103 int prevMax = c->
max();
106 while (q->next() != NULL && q->next()->min() <= ma+1) {
108 growth += q->min()-prevMax-1;
114 _size += ma-q->max();
117 d._glbMax = q->min()-1;
121 RangeList* oldCNext = c->
next();
122 assert(oldCNext!=NULL);
124 if (q->next()==NULL){
128 oldCNext->dispose(home,q);
132 RangeList* nc = c->
next();
137 RangeList* q =
new (home) RangeList(mi, ma, NULL);
147 LUBndSet::intersect_full(Space& home,
int mi,
int ma) {
149 RangeList* c =
fst();
154 while (c != NULL && c->max() < mi) {
156 RangeList *nc = c->next();
166 bool changed =
false;
175 _size -= mi-c->min();
180 while (c != NULL && c->max() <= ma) {
181 RangeList *nc = c->next();
188 RangeList* newlst =
p;
189 if (ma >= c->min()) {
190 _size -= c->max() - ma;
193 RangeList* nc = c->next();
196 }
else if (p != NULL) {
200 for (RangeList* cc = c ; cc != NULL; cc = cc->next())
201 _size -= cc->width();
202 c->dispose(home,
lst());
211 LUBndSet::exclude_full(Space& home,
int mi,
int ma, SetDelta& d) {
213 assert(mi <=
max() && ma >=
min() &&
214 (mi >
min() || ma <
max()));
218 RangeList* c =
fst();
222 if (c->min() > ma) {
return result; }
224 if (c->min()<mi && c->max() > ma) {
226 new (home) RangeList(ma+1,c->max(),c->next());
239 d._lubMin =
std::min(d._lubMin, c->min());
241 _size-=(ma-c->min()+1);
247 _size-=(c->max()-mi+1);
249 d._lubMax = c->max();
253 d._lubMin = c->min();
256 while ((cend->next()!=NULL) && (cend->next()->max()<=ma)){
258 _size-=cend->width();
260 d._lubMax = cend->max();
264 p->
next(cend->next());
269 RangeList* nc=cend->next();
270 c->dispose(home,cend);
273 if (c != NULL && c->min() <= ma ) {
275 _size-=(ma-c->min()+1);
282 RangeList *nc = c->next();
296 if (lst()!=NULL ||
size()!=0) {
297 std::cerr<<
"Strange empty set.\n";
302 if (fst()!=NULL && lst()==NULL) {
303 std::cerr<<
"First is not null, last is.\n";
314 std::cerr <<
"Single range list twisted: ("<<min<<
","<<max<<
")" ;
325 if ((max+1)>=c->
min()) {
329 if (c->
next()==NULL && c!=lst()) {
RangeList * lst(void) const
Return last range.
bool isConsistent(void) const
Check whether internal invariants hold.
const FloatNum max
Largest allowed float value.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
int min(void) const
Return minimum.
const int max
Largest allowed integer in integer set.
int max(void) const
Return maximum.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
int ranges(void) const
Return number of ranges of the specification.
RangeList * fst(void) const
Return first range.
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.
unsigned int _size
The size of this set.
RangeList * next(void) const
Return next element.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
int min(void) const
Return smallest element.
void dispose(Space &home, RangeList *l)
Free memory for all elements between this and l (inclusive)
Lists of ranges (intervals)
Gecode toplevel namespace
BndSet(void)
Default constructor. Creates an empty set.
int max(void) const
Return greatest element.
int max(int i) const
Return maximum of range at position i.
int min(int i) const
Return minimum of range at position i.
Finite set delta information for advisors.