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

Method post

gecode/int/arithmetic/argmax.hpp:47–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46 template<class VA, class VB, bool tiebreak>
47 ExecStatus
48 ArgMax<VA,VB,tiebreak>::post(Home home, IdxViewArray<VA>& x, VB y) {
49 assert(x.size() > 0);
50 if (x.size() == 1) {
51 GECODE_ME_CHECK(y.eq(home,x[0].idx));
52 } else if (y.assigned()) {
53 int max=0;
54 while (x[max].idx < y.val())
55 max++;
56 assert(x[max].idx == y.val());
57 if (tiebreak)
58 for (int i=0; i<max; i++)
59 GECODE_ES_CHECK((Rel::Le<VA,VA>::post(home,
60 x[i].view,x[max].view)));
61 else
62 for (int i=0; i<max; i++)
63 GECODE_ES_CHECK((Rel::Lq<VA,VA>::post(home,
64 x[i].view,x[max].view)));
65 for (int i=max+1; i<x.size(); i++)
66 GECODE_ES_CHECK((Rel::Lq<VA,VA>::post(home,
67 x[i].view,x[max].view)));
68 } else {
69 (void) new (home) ArgMax<VA,VB,tiebreak>(home,x,y);
70 }
71 return ES_OK;
72 }
73
74 template<class VA, class VB, bool tiebreak>
75 forceinline

Callers

nothing calls this directly

Calls 5

postFunction · 0.50
sizeMethod · 0.45
eqMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected