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

Function scan

gecode/int/element/view.hpp:216–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214
215 template<class VA, class VB, class VC, PropCond pc_ac, class RelTest>
216 ExecStatus
217 scan(Space& home, IdxViewArray<VA>& iv,
218 VB x0, VC x1, Propagator& p, RelTest rt) {
219 assert(iv.size() > 1);
220 /*
221 * Prunes pairs of index, variable
222 * - checks for idx value removed
223 * - checks for disequal variables
224 *
225 */
226 ViewValues<VB> vx0(x0);
227 int i = 0;
228 int j = 0;
229 while (vx0() && (i < iv.size())) {
230 if (iv[i].idx < vx0.val()) {
231 iv[i].view.cancel(home,p,pc_ac);
232 ++i;
233 } else if (iv[i].idx > vx0.val()) {
234 ++vx0;
235 } else {
236 assert(iv[i].idx == vx0.val());
237 switch (rt(iv[i].view,x1)) {
238 case RT_FALSE:
239 iv[i].view.cancel(home,p,pc_ac);
240 break;
241 case RT_TRUE:
242 case RT_MAYBE:
243 iv[j++] = iv[i];
244 break;
245 default: GECODE_NEVER;
246 }
247 ++vx0; ++i;
248 }
249 }
250 while (i < iv.size())
251 iv[i++].view.cancel(home,p,pc_ac);
252 bool adjust = (j<iv.size());
253 iv.size(j);
254
255 if (iv.size() == 0)
256 return ES_FAILED;
257
258 if (iv.size() == 1) {
259 GECODE_ME_CHECK(x0.eq(home,iv[0].idx));
260 } else if (adjust) {
261 IterIdxView<VA> v(&iv[0],&iv[0]+iv.size());
262 GECODE_ME_CHECK(x0.narrow_v(home,v,false));
263 assert(x0.size() == static_cast<unsigned int>(iv.size()));
264 }
265 return ES_OK;
266 }
267
268
269

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.45
valMethod · 0.45
cancelMethod · 0.45
eqMethod · 0.45
narrow_vMethod · 0.45

Tested by

no test coverage detected