MCPcopy Create free account
hub / github.com/Gecode/gecode / nq_full

Method nq_full

gecode/int/var-imp/int.cpp:179–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177 }
178
179 ModEvent
180 IntVarImp::nq_full(Space& home, int m) {
181 assert(!((m < dom.min()) || (m > dom.max())));
182 ModEvent me = ME_INT_DOM;
183 if (range()) {
184 if ((m == dom.min()) && (m == dom.max()))
185 return fail(home);
186 if (m == dom.min()) {
187 dom.min(m+1);
188 me = assigned() ? ME_INT_VAL : ME_INT_BND;
189 } else if (m == dom.max()) {
190 dom.max(m-1);
191 me = assigned() ? ME_INT_VAL : ME_INT_BND;
192 } else {
193 RangeList* f = new (home) RangeList(dom.min(),m-1);
194 RangeList* l = new (home) RangeList(m+1,dom.max());
195 f->prevnext(nullptr,l);
196 l->prevnext(f,nullptr);
197 fst(f); lst(l); holes = 1;
198 }
199 } else if (m < fst()->next(nullptr)->min()) { // Concerns the first range...
200 int f_max = fst()->max();
201 if (m > f_max)
202 return ME_INT_NONE;
203 int f_min = dom.min();
204 if ((m == f_min) && (m == f_max)) {
205 RangeList* f_next = fst()->next(nullptr);
206 dom.min(f_next->min());
207 if (f_next == lst()) { // Turns into range
208 // Works as at the ends there are only nullptr pointers
209 fst()->dispose(home,f_next);
210 fst(nullptr); holes = 0;
211 me = assigned() ? ME_INT_VAL : ME_INT_BND;
212 } else { // Remains non-range
213 f_next->prev(fst(),nullptr);
214 fst()->dispose(home); fst(f_next);
215 holes -= dom.min() - f_min - 1;
216 me = ME_INT_BND;
217 }
218 } else if (m == f_min) {
219 dom.min(m+1); fst()->min(m+1);
220 me = ME_INT_BND;
221 } else if (m == f_max) {
222 fst()->max(m-1); holes += 1;
223 } else {
224 // Create new hole
225 RangeList* f = new (home) RangeList(f_min,m-1);
226 f->prevnext(nullptr,fst());
227 fst()->min(m+1); fst()->prev(nullptr,f);
228 fst(f); holes += 1;
229 }
230 } else if (m > lst()->prev(nullptr)->max()) { // Concerns the last range...
231 int l_min = lst()->min();
232 if (m < l_min)
233 return ME_INT_NONE;
234 int l_max = dom.max();
235 if ((m == l_min) && (m == l_max)) {
236 RangeList* l_prev = lst()->prev(nullptr);

Callers

nothing calls this directly

Calls 8

rangeFunction · 0.85
assignedFunction · 0.85
prevnextMethod · 0.80
minMethod · 0.45
maxMethod · 0.45
nextMethod · 0.45
disposeMethod · 0.45
prevMethod · 0.45

Tested by

no test coverage detected