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

Method post

gecode/int/nvalues/bool-gq.hpp:55–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54 template<class VY>
55 inline ExecStatus
56 GqBool<VY>::post(Home home, ViewArray<BoolView>& x, VY y) {
57 if (x.size() == 0) {
58 GECODE_ME_CHECK(y.lq(home,0));
59 return ES_OK;
60 }
61
62 x.unique();
63
64 if (x.size() == 1) {
65 GECODE_ME_CHECK(y.lq(home,1));
66 return ES_OK;
67 }
68
69 GECODE_ME_CHECK(y.lq(home,2));
70
71 if (y.max() <= 1)
72 return ES_OK;
73
74 if (y.min() == 2) {
75 assert(y.assigned());
76 ViewArray<BoolView> xc(home,x);
77 return Rel::NaryNq<BoolView>::post(home,xc);
78 }
79
80 int n = x.size();
81 int status = 0;
82 for (int i=n; i--; )
83 if (x[i].zero()) {
84 if (status & VS_ONE)
85 return ES_OK;
86 x[i] = x[--n];
87 status |= VS_ZERO;
88 } else if (x[i].one()) {
89 if (status & VS_ZERO)
90 return ES_OK;
91 x[i] = x[--n];
92 status |= VS_ONE;
93 }
94
95 assert(status != (VS_ZERO | VS_ONE));
96 if (n == 0) {
97 assert(status != 0);
98 GECODE_ME_CHECK(y.lq(home,1));
99 return ES_OK;
100 }
101 x.size(n);
102
103 (void) new (home) GqBool<VY>(home,status,x,y);
104 return ES_OK;
105 }
106
107 template<class VY>
108 ExecStatus

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
zeroMethod · 0.45
oneMethod · 0.45

Tested by

no test coverage detected