本文整理汇总了C++中ViewArray类的典型用法代码示例。如果您正苦于以下问题:C++ ViewArray类的具体用法?C++ ViewArray怎么用?C++ ViewArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
inline ExecStatus
NaryNq<View>::post(Home home, ViewArray<View>& x) {
x.unique(home);
// Try to find an assigned view
int n = x.size();
if (n <= 1)
return ES_FAILED;
for (int i=n; i--; )
if (x[i].assigned()) {
std::swap(x[0],x[i]);
break;
}
if (x[0].assigned()) {
int v = x[0].val();
// Eliminate all equal views and possibly find disequal view
for (int i=n-1; i>0; i--)
if (!x[i].in(v)) {
return ES_OK;
} else if (x[i].assigned()) {
assert(x[i].val() == v);
x[i]=x[--n];
}
x.size(n);
}
if (n == 1)
return ES_FAILED;
if (n == 2)
return Nq<View>::post(home,x[0],x[1]);
(void) new (home) NaryNq(home,x);
return ES_OK;
}
示例2: vsr
inline ExecStatus
Prop<View>::post(Home home, ViewArray<View>& x, View y) {
if (x.size() == 0)
return ES_FAILED;
x.unique(home);
if (x.size() == 1)
return Rel::EqDom<View,View>::post(home,x[0],y);
if (x.same(home,y))
return ES_OK;
// Eliminate assigned views and store them into the value set
ValSet vs;
add(home, vs, x);
if (x.size() == 0) {
ValSet::Ranges vsr(vs);
GECODE_ME_CHECK(y.inter_r(home,vsr,false));
return ES_OK;
}
(void) new (home) Prop<View>(home, vs, x, y);
return ES_OK;
}
示例3: NoOverlap
// Create propagator and initialize
NoOverlap(Home home,
ViewArray<IntView>& x0, int w0[],
ViewArray<IntView>& y0, int h0[])
: Propagator(home), x(x0), w(w0), y(y0), h(h0) {
x.subscribe(home,*this,PC_INT_BND);
y.subscribe(home,*this,PC_INT_BND);
}
示例4: n
ExecStatus
NaryEqv::post(Home home, ViewArray<BoolView>& x, int pm2) {
int n = x.size();
for (int i=n; i--; )
if (x[i].assigned()) {
pm2 ^= x[i].val();
x[i] = x[--n];
}
if (n == 0)
return (pm2 == 1) ? ES_OK : ES_FAILED;
if (n == 1) {
GECODE_ME_CHECK(x[0].eq(home,1^pm2));
return ES_OK;
}
if (n == 2) {
if (pm2 == 1) {
return Bool::Eq<BoolView,BoolView>::post(home,x[0],x[1]);
} else {
NegBoolView n(x[1]);
return Bool::Eq<BoolView,NegBoolView>::post(home,x[0],n);
}
}
x.size(n);
(void) new (home) NaryEqv(home,x,pm2);
return ES_OK;
}
示例5: r
forceinline
Incremental<View>::Incremental(Home home, ViewArray<View>& x,
const TupleSet& t)
: Base<View,false>(home,x,t), support_data(NULL),
unassigned(x.size()), ac(home) {
init_support(home);
// Post advisors
for (int i = x.size(); i--; )
if (x[i].assigned()) {
--unassigned;
} else {
x[i].subscribe(home,*new (home) SupportAdvisor(home,*this,ac,i));
}
Region r(home);
// Add initial supports
BitSet* dom = r.alloc<BitSet>(x.size());
init_dom(home, dom);
for (int i = x.size(); i--; )
for (ViewValues<View> vv(x[i]); vv(); ++vv)
find_support(home, dom, i, vv.val());
// Work to be done or subsumption
if (!w_support.empty() || !w_remove.empty() || (unassigned == 0))
View::schedule(home,*this,
(unassigned != x.size()) ? ME_INT_VAL : ME_INT_DOM);
}
示例6: post_false
ExecStatus
EqInt<VX,VY>::post(Home home, ViewArray<VX>& x, VY y, int c) {
// Eliminate decided views
int n_x = x.size();
for (int i=n_x; i--; )
switch (holds(x[i],y)) {
case RT_FALSE:
x[i] = x[--n_x]; break;
case RT_TRUE:
x[i] = x[--n_x]; c--; break;
case RT_MAYBE:
break;
default:
GECODE_NEVER;
}
x.size(n_x);
// RHS too small or too large
if ((c < 0) || (c > n_x))
return ES_FAILED;
// All views must be different
if (c == 0)
return post_false(home,x,y);
// All views must be equal
if (c == n_x)
return post_true(home,x,y);
// Compute how many subscriptions must be created
int n_s = std::max(c,n_x-c)+1;
assert(n_s <= n_x);
(void) new (home) EqInt<VX,VY>(home,x,n_s,y,c);
return ES_OK;
}
示例7: if
ExecStatus
EqBoolView<XV,YV>::post(Home home, ViewArray<XV>& x, YV y, int c) {
if (y.assigned())
return EqBoolInt<XV>::post(home,x,y.val()+c);
int n = x.size();
for (int i = n; i--; )
if (x[i].one()) {
x[i]=x[--n]; c--;
} else if (x[i].zero()) {
x[i]=x[--n];
}
x.size(n);
GECODE_ME_CHECK(y.lq(home,n-c));
GECODE_ME_CHECK(y.gq(home,-c));
if (n == 0)
return ES_OK;
if (y.min()+c == n) {
assert(y.assigned());
for (int i = n; i--; )
GECODE_ME_CHECK(x[i].one_none(home));
return ES_OK;
}
if (y.max()+c == 0) {
assert(y.assigned());
for (int i = n; i--; )
GECODE_ME_CHECK(x[i].zero_none(home));
return ES_OK;
}
(void) new (home) EqBoolView<XV,YV>(home,x,y,c);
return ES_OK;
}
示例8: post_true
ExecStatus
GqInt<VX,VY>::post(Home home, ViewArray<VX>& x, VY y, int c) {
// Eliminate decided views
int n_x = x.size();
for (int i=n_x; i--; )
switch (holds(x[i],y)) {
case RT_FALSE:
x[i] = x[--n_x]; break;
case RT_TRUE:
x[i] = x[--n_x]; c--; break;
case RT_MAYBE:
break;
default:
GECODE_NEVER;
}
x.size(n_x);
// RHS too large
if (n_x < c)
return ES_FAILED;
// Whatever the x[i] take for values, the inequality is subsumed
if (c <= 0)
return ES_OK;
// All views must be equal
if (c == n_x)
return post_true(home,x,y);
(void) new (home) GqInt<VX,VY>(home,x,c+1,y,c);
return ES_OK;
}
示例9: post_false
ExecStatus
LqInt<VX,VY>::post(Home home, ViewArray<VX>& x, VY y, int c) {
// Eliminate decided views
int n_x = x.size();
for (int i=n_x; i--; )
switch (holds(x[i],y)) {
case RT_FALSE:
x[i] = x[--n_x]; break;
case RT_TRUE:
x[i] = x[--n_x]; c--; break;
case RT_MAYBE:
break;
default:
GECODE_NEVER;
}
x.size(n_x);
if (c < 0)
return ES_FAILED;
if (c >= n_x)
return ES_OK;
// All views must be different
if (c == 0)
return post_false(home,x,y);
(void) new (home) LqInt<VX,VY>(home,x,n_x-c+1,y,c);
return ES_OK;
}
示例10: normalize
inline bool
normalize(Space& home,
ViewArray<View>& y,
ViewArray<View>& x,
bool& nofix) {
int ys = y.size();
for (int i = 1; i < ys; i++) {
ModEvent me_lb = y[i].gq(home, y[i - 1].min());
if (me_failed(me_lb))
return false;
nofix |= (me_modified(me_lb) && y[i - 1].min() != y[i].min());
}
for (int i = ys - 1; i--; ) {
ModEvent me_ub = y[i].lq(home, y[i + 1].max());
if (me_failed(me_ub))
return false;
nofix |= (me_modified(me_ub) && y[i + 1].max() != y[i].max());
}
int xs = x.size();
for (int i = xs; i--; ) {
ModEvent me = x[i].gq(home, y[0].min());
if (me_failed(me))
return false;
nofix |= (me_modified(me) && x[i].min() != y[0].min());
me = x[i].lq(home, y[xs - 1].max());
if (me_failed(me))
return false;
nofix |= (me_modified(me) && x[i].max() != y[xs - 1].max());
}
return true;
}
示例11: post_true
forceinline ExecStatus
post_true(Home home, ViewArray<VX>& x, VX y) {
ViewArray<VX> z(home,x.size()+1);
z[x.size()] = y;
for (int i = x.size(); i--; )
z[i] = x[i];
return Rel::NaryEqDom<VX>::post(home,z);
}
示例12: new
ExecStatus
Val<View>::post(Home home, ViewArray<View>& x) {
if (x.size() == 2)
return Rel::Nq<View>::post(home,x[0],x[1]);
if (x.size() > 2)
(void) new (home) Val<View>(home,x);
return ES_OK;
}
示例13: sort_tau
inline void
sort_tau(ViewArray<View>& x, ViewArray<View>& z, int tau[]) {
if (Perm) {
TupleMaxIncExt<View> ltmax(x,z);
Support::quicksort(&(*tau), x.size(), ltmax);
} else {
TupleMaxInc<View> ltmax(x);
Support::quicksort(&(*tau), x.size(), ltmax);
}
}
示例14:
forceinline void
Prop<View>::add(Space& home, ValSet& vs, ViewArray<View>& x) {
int n=x.size();
for (int i=n; i--; )
if (x[i].assigned()) {
vs.add(home, x[i].val());
x[i] = x[--n];
}
x.size(n);
}
示例15: GECODE_ME_CHECK
inline ExecStatus
LqBool<VY>::post(Home home, ViewArray<BoolView>& x, VY y) {
if (x.size() == 0) {
GECODE_ME_CHECK(y.gq(home,0));
return ES_OK;
}
x.unique(home);
GECODE_ME_CHECK(y.gq(home,1));
if (x.size() == 1)
return ES_OK;
if (y.max() == 1) {
assert(y.assigned());
ViewArray<BoolView> xc(home,x);
return Bool::NaryEq<BoolView>::post(home,xc);
}
if (y.min() >= 2)
return ES_OK;
int n = x.size();
int status = 0;
for (int i=n; i--; )
if (x[i].zero()) {
if (status & VS_ONE) {
GECODE_ME_CHECK(y.gq(home,2));
return ES_OK;
}
x[i] = x[--n];
status |= VS_ZERO;
} else if (x[i].one()) {
if (status & VS_ZERO) {
GECODE_ME_CHECK(y.gq(home,2));
return ES_OK;
}
x[i] = x[--n];
status |= VS_ONE;
}
assert(status != (VS_ZERO | VS_ONE));
if (n == 0) {
assert((status != 0) && (y.min() >= 1));
return ES_OK;
}
x.size(n);
(void) new (home) LqBool<VY>(home,status,x,y);
return ES_OK;
}