38namespace Gecode {
namespace Set {
48 for (
int i =
n; i--; ) {
50 r[i].min(is.
min(i));
r[i].max(is.
max(i));
60 GLBndSet::include_full(
Space& home,
int mi,
int ma,
SetDelta& d) {
62 assert(
fst() != NULL);
68 if (c->
max() >= mi-1) {
69 if (c->
min() > ma+1) {
89 d._glbMin = c->
max()+1;
92 assert(
c->
max()+1>=mi);
94 d._glbMax =
c->
min()-1;
99 int prevMax =
c->
max();
102 while (q->next() != NULL && q->next()->min() <= ma+1) {
104 growth += q->min()-prevMax-1;
110 _size += ma-q->max();
113 d._glbMax = q->
min()-1;
115 c->
max(std::max(ma,q->max()));
117 RangeList* oldCNext =
c->next();
118 assert(oldCNext!=NULL);
120 if (q->next()==NULL) {
124 oldCNext->dispose(home,q);
128 RangeList* nc =
c->next();
133 RangeList* q =
new (home) RangeList(mi, ma, NULL);
143 LUBndSet::intersect_full(Space& home,
int mi,
int ma) {
145 RangeList*
c =
fst();
150 while (c != NULL &&
c->
max() < mi) {
152 RangeList *nc =
c->next();
162 bool changed =
false;
176 while (c != NULL &&
c->
max() <= ma) {
177 RangeList *nc =
c->next();
184 RangeList* newlst =
p;
185 if (ma >=
c->
min()) {
189 RangeList* nc =
c->next();
192 }
else if (
p != NULL) {
196 for (RangeList* cc = c ; cc != NULL; cc = cc->next())
197 _size -= cc->width();
198 c->dispose(home,
lst());
207 LUBndSet::exclude_full(Space& home,
int mi,
int ma, SetDelta& d) {
209 assert(mi <=
max() && ma >=
min() &&
210 (mi >
min() || ma <
max()));
214 RangeList*
c =
fst();
217 if (
c->
max() >= mi) {
218 if (
c->
min() > ma) {
return result; }
222 new (home) RangeList(ma+1,
c->
max(),
c->next());
235 d._lubMin = std::min(
d._lubMin,
c->
min());
245 d._lubMax =
c->
max();
249 d._lubMin =
c->
min();
252 while ((cend->next()!=NULL) && (cend->next()->max()<=ma)) {
254 _size-=cend->width();
256 d._lubMax = cend->
max();
260 p->next(cend->next());
265 RangeList* nc=cend->next();
266 c->dispose(home,cend);
269 if (c != NULL &&
c->
min() <= ma ) {
278 RangeList *nc =
c->next();
292 if (
lst()!=NULL ||
size()!=0) {
293 std::cerr<<
"Strange empty set.\n";
298 if (
fst()!=NULL &&
lst()==NULL) {
299 std::cerr<<
"First is not null, last is.\n";
310 std::cerr <<
"Single range list twisted: ("<<
min<<
","<<
max<<
")" ;
325 if (c->next()==NULL && c!=
lst()) {
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
friend FloatVal min(const FloatVal &x, const FloatVal &y)
int min(int i) const
Return minimum of range at position i.
int max(int i) const
Return maximum of range at position i.
int ranges(void) const
Return number of ranges of the specification.
unsigned int width(int i) const
Return width of range at position i.
Lists of ranges (intervals)
void dispose(Space &home, RangeList *l)
Free memory for all elements between this and l (inclusive)
RangeList * next(void) const
Return next element.
int min(void) const
Return smallest element.
bool isConsistent(void) const
Check whether internal invariants hold.
RangeList * lst(void) const
Return last range.
unsigned int size(void) const
Return size.
BndSet(void)
Default constructor. Creates an empty set.
int max(void) const
Return greatest element.
unsigned int _size
The size of this set.
RangeList * fst(void) const
Return first range.
Finite set delta information for advisors.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
const int max
Largest allowed integer in integer set.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
Gecode::FloatVal c(-8, 8)