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();
289 using namespace Gecode::Int;
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()) {