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

Function valid

test/int/cumulatives.cpp:166–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 /// Check whether event \a e is valid
165 template<class C>
166 bool valid(std::vector<Event> e, C comp) {
167 std::sort(e.begin(), e.end());
168 unsigned int i = 0;
169 int p = 0;
170 int h = 0;
171 int n = 0;
172 while (i < e.size()) {
173 p = e[i].p;
174 while (i < e.size() && e[i].p == p) {
175 h += e[i].h;
176 n += (e[i].start ? +1 : -1);
177 ++i;
178 }
179 if (n && !comp(h))
180 return false;
181 }
182 return true;
183 }
184
185 /// %Test for cumulatives constraint
186 class Cumulatives : public Test {

Callers 10

solutionMethod · 0.85
SpecMethod · 0.85
SpecMethod · 0.85
operator +Function · 0.85
operator -Function · 0.85
operator *Function · 0.85
operator +Function · 0.85
operator -Function · 0.85
operator *Function · 0.85
checkMethod · 0.85

Calls 4

sortFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected