45 namespace Gecode {
namespace Set {
namespace Int {
98 while (elements[index]<iter.val()) index++;
99 assert(elements[index]==iter.val());
100 if (
weights[index] > threshold) {
116 I&
i) : threshold(t),
130 threshold = t; iter =
i;
131 elements = elements0;
weights = weights0;
165 x.update(home,share,p.
x);
176 if (elements.
size() != weights.
size())
179 int* els_arr = r.
alloc<
int>(elements.
size());
180 for (
int i=elements.
size();
i--;)
181 els_arr[
i] = elements[
i];
185 (void)
new (home)
Weights(home,elements,weights,x,y);
201 elements.~SharedArray();
204 return sizeof(*this);
210 return new (home)
Weights(home,share,*
this);
224 while (elements[i]<v.
val()) i++;
225 assert(elements[i] == v.
val());
252 int size = elements.size();
254 int* currentWeights = r.
alloc<
int>(
size);
259 if (!urv() || elements[
i]<urv.
val()) {
260 currentWeights[
i] = 0;
262 assert(elements[
i] == urv.
val());
270 Support::quicksort<int>(currentWeights,
size, il);
273 int delta =
static_cast<int>(
std::min(x.unknownSize(), x.cardMax() - x.glbSize()));
277 int glbWeight = weightI<GlbRanges<View> >(elements,
weights, glb);
284 int lowWeight = glbWeight;
285 for (
int i=0;
i<delta-1;
i++) {
286 if (currentWeights[
i] >= 0)
288 lowWeight+=currentWeights[
i];
294 int lowestWeight = lowWeight;
295 if (delta>0 && currentWeights[delta-1]<0)
296 lowestWeight+=currentWeights[delta-1];
301 if ( (x.cardMin() - x.glbSize() > 0 &&
302 currentWeights[x.cardMin() - x.glbSize() - 1] >= 0) ||
303 currentWeights[0] >= 0 ) {
304 int lowestPosWeight = glbWeight;
305 for (
unsigned int i=0;
i<x.cardMin() - x.glbSize();
i++) {
306 lowestPosWeight += currentWeights[
i];
308 lowestWeight =
std::max(lowestWeight, lowestPosWeight);
314 int highestWeight = glbWeight;
315 for (
int i=0;
i<delta;
i++) {
316 if (currentWeights[size-
i-1]<=0)
318 highestWeight += currentWeights[size-
i-1];
328 int remainingCapacity = y.max()-lowWeight;
333 ov(remainingCapacity, elements, weights, urv2);
336 me = x.excludeI(home, ovr);
343 weightI<GlbRanges<View> >(elements,
weights, glb);