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

Method post

gecode/int/nvalues/int-gq.hpp:45–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected