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

Method post

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

postFunction · 0.50
sizeMethod · 0.45
gqMethod · 0.45
uniqueMethod · 0.45
maxMethod · 0.45
assignedMethod · 0.45
minMethod · 0.45
zeroMethod · 0.45
oneMethod · 0.45

Tested by

no test coverage detected