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

Method post

gecode/int/nvalues/int-eq.hpp:47–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46 template<class VY>
47 inline ExecStatus
48 EqInt<VY>::post(Home home, ViewArray<IntView>& x, VY y) {
49 if (x.size() == 0) {
50 GECODE_ME_CHECK(y.eq(home,0));
51 return ES_OK;
52 }
53
54 x.unique();
55
56 if (x.size() == 1) {
57 GECODE_ME_CHECK(y.eq(home,1));
58 return ES_OK;
59 }
60
61 GECODE_ME_CHECK(y.gq(home,1));
62 GECODE_ME_CHECK(y.lq(home,x.size()));
63
64 if (y.max() == 1) {
65 assert(y.assigned());
66 return Rel::NaryEqDom<IntView>::post(home,x);
67 }
68
69 if (y.min() == x.size()) {
70 assert(y.assigned());
71 return Distinct::Dom<IntView>::post(home,x);
72 }
73
74 // Eliminate assigned views and store them into the value set
75 ValSet vs;
76 int n = x.size();
77 for (int i=n; i--; )
78 if (x[i].assigned()) {
79 vs.add(home, x[i].val());
80 x[i] = x[--n];
81 }
82
83 GECODE_ME_CHECK(y.gq(home,vs.size()));
84 GECODE_ME_CHECK(y.lq(home,n + vs.size()));
85
86 if (n == 0) {
87 assert(y.val() == vs.size());
88 return ES_OK;
89 }
90 x.size(n);
91 (void) new (home) EqInt<VY>(home, vs, x, y);
92 return ES_OK;
93 }
94
95 template<class VY>
96 forceinline

Callers

nothing calls this directly

Calls 11

postFunction · 0.50
sizeMethod · 0.45
eqMethod · 0.45
uniqueMethod · 0.45
gqMethod · 0.45
lqMethod · 0.45
maxMethod · 0.45
assignedMethod · 0.45
minMethod · 0.45
addMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected