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

Method med

gecode/int/var-imp/int.cpp:45–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 }
44
45 int
46 IntVarImp::med(void) const {
47 // Computes the median
48 if (fst() == nullptr)
49 return (dom.min()+dom.max())/2 - ((dom.min()+dom.max())%2 < 0 ? 1 : 0);
50 unsigned int i = size() / 2;
51 if (size() % 2 == 0)
52 i--;
53 const RangeList* p = nullptr;
54 const RangeList* c = fst();
55 while (i >= c->width()) {
56 i -= c->width();
57 const RangeList* n=c->next(p); p=c; c=n;
58 }
59 return c->min() + static_cast<int>(i);
60 }
61
62 bool
63 IntVarImp::in_full(int m) const {

Callers

nothing calls this directly

Calls 5

sizeFunction · 0.50
minMethod · 0.45
maxMethod · 0.45
widthMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected