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

Function count

gecode/int/gcc.cpp:99–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97 }
98
99 void count(Home home, const IntVarArgs& x,
100 const IntVarArgs& _c, const IntArgs& _v,
101 IntPropLevel ipl) {
102 using namespace Int;
103 IntVarArgs c(_c);
104 IntArgs v(_v);
105 if (v.size() != c.size())
106 throw ArgumentSizeMismatch("Int::count");
107 if (same(x))
108 throw ArgumentSame("Int::count");
109
110 GECODE_POST;
111
112 removeDuplicates(home,c,v);
113
114 ViewArray<IntView> xv(home, x);
115 ViewArray<GCC::CardView> cv(home, c.size());
116 // set the cardinality
117 for (int i=0; i<v.size(); i++)
118 cv[i].init(c[i],v[i]);
119 switch (vbd(ipl)) {
120 case IPL_BND:
121 GECODE_ES_FAIL(
122 (GCC::Bnd<GCC::CardView>::post(home,xv,cv)));
123 break;
124 case IPL_DOM:
125 GECODE_ES_FAIL(
126 (GCC::Dom<GCC::CardView>::post(home,xv,cv)));
127 break;
128 default:
129 GECODE_ES_FAIL(
130 (GCC::Val<GCC::CardView>::post(home,xv,cv)));
131 }
132 }
133
134 // domain is 0..|cards|- 1
135 void count(Home home, const IntVarArgs& x, const IntVarArgs& c,

Callers 15

postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50
postMethod · 0.50

Calls 9

removeDuplicatesFunction · 0.85
sameFunction · 0.50
postFunction · 0.50
checkFunction · 0.50
sizeMethod · 0.45
initMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
rangesMethod · 0.45

Tested by

no test coverage detected