本文整理汇总了C++中ViewArray类的典型用法代码示例。如果您正苦于以下问题:C++ ViewArray类的具体用法?C++ ViewArray怎么用?C++ ViewArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Wushaowei001,项目名称:gecode-clone,代码行数:31,代码来源:nq.hpp
示例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;
}
开发者ID:Wushaowei001,项目名称:crossbow,代码行数:26,代码来源:prop.hpp
示例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);
}
开发者ID:ksallberg,项目名称:lekstugan,代码行数:8,代码来源:no-overlap.cpp
示例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;
}
开发者ID:Wushaowei001,项目名称:crossbow,代码行数:26,代码来源:eqv.cpp
示例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);
}
开发者ID:celikpence,项目名称:gecode,代码行数:29,代码来源:incremental.hpp
示例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;
}
开发者ID:kenhys,项目名称:gecode,代码行数:31,代码来源:int-eq.hpp
示例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;
}
开发者ID:Wushaowei001,项目名称:crossbow,代码行数:31,代码来源:bool-view.hpp
示例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;
}
开发者ID:kenhys,项目名称:gecode,代码行数:28,代码来源:int-gq.hpp
示例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;
}
开发者ID:YoshihisaMaruya,项目名称:tool_test_chef,代码行数:26,代码来源:int-lq.hpp
示例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;
}
开发者ID:celikpence,项目名称:gecode,代码行数:35,代码来源:order.hpp
示例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);
}
开发者ID:MGKhKhD,项目名称:easy-IP,代码行数:8,代码来源:rel.hpp
示例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;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例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);
}
}
开发者ID:celikpence,项目名称:gecode,代码行数:10,代码来源:order.hpp
示例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);
}
开发者ID:Wushaowei001,项目名称:crossbow,代码行数:10,代码来源:prop.hpp
示例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;
}
开发者ID:celikpence,项目名称:gecode,代码行数:53,代码来源:bool-lq.hpp
示例16: prune
forceinline ExecStatus
prune(Space& home, ViewArray<VX>& x, VX y) {
if (x.size() == 0)
return ES_OK;
Region r(home);
ViewRanges<VX>* rx = r.alloc<ViewRanges<VX> >(x.size());
for (int i=x.size(); i--; )
rx[i] = ViewRanges<VX>(x[i]);
Iter::Ranges::NaryUnion u(r, rx, x.size());
GECODE_ME_CHECK(y.inter_r(home, u, false));
return ES_OK;
}
开发者ID:MGKhKhD,项目名称:easy-IP,代码行数:12,代码来源:rel.hpp
示例17: switch
forceinline ExecStatus
SeqU::post(Home home, ViewArray<SetView> x, SetView y) {
switch (x.size()) {
case 0:
GECODE_ME_CHECK(y.cardMax(home, 0));
return ES_OK;
case 1:
return Rel::Eq<SetView,SetView>::post(home, x[0], y);
default:
if (x.shared(home) || x.shared(home,y))
return ES_FAILED;
(void) new (home) SeqU(home,x,y);
return ES_OK;
}
}
开发者ID:MGKhKhD,项目名称:easy-IP,代码行数:15,代码来源:seq-u.hpp
示例18: new
forceinline ExecStatus
ChannelBool<View>::post(Home home, ViewArray<Gecode::Int::BoolView>& x,
View y) {
GECODE_ME_CHECK(y.intersect(home, 0, x.size()-1));
(void) new (home) ChannelBool(home,x,y);
return ES_OK;
}
开发者ID:celikpence,项目名称:gecode,代码行数:7,代码来源:channel-bool.hpp
示例19: c
forceinline
LinkMulti::LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0)
: MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>
(home,x,y), c(home), status(S_NONE), o(o0) {
x.subscribe(home,*new (home) Advisor(home,*this,c));
// Propagator is scheduled because of the dependency subscription
}
开发者ID:Wushaowei001,项目名称:gecode-clone,代码行数:7,代码来源:link-multi.hpp
示例20: assert
forceinline ExecStatus
LinkMulti::post(Home home, ViewArray<BoolView>& x, IntView y, int o) {
int n=x.size();
GECODE_ME_CHECK(y.gq(home,o));
GECODE_ME_CHECK(y.lq(home,o+n-1));
assert(n > 0);
if (n == 1) {
GECODE_ME_CHECK(x[0].one(home));
assert(y.val() == o);
} else if (y.assigned()) {
int j=y.val()-o;
GECODE_ME_CHECK(x[j].one(home));
for (int i=0; i<j; i++)
GECODE_ME_CHECK(x[i].zero(home));
for (int i=j+1; i<n; i++)
GECODE_ME_CHECK(x[i].zero(home));
} else {
for (int i=n; i--; )
if (x[i].one()) {
for (int j=0; j<i; j++)
GECODE_ME_CHECK(x[j].zero(home));
for (int j=i+1; j<n; j++)
GECODE_ME_CHECK(x[j].zero(home));
GECODE_ME_CHECK(y.eq(home,o+i));
return ES_OK;
} else if (x[i].zero()) {
GECODE_ME_CHECK(y.nq(home,o+i));
}
(void) new (home) LinkMulti(home,x,y,o);
}
return ES_OK;
}
开发者ID:Wushaowei001,项目名称:gecode-clone,代码行数:32,代码来源:link-multi.hpp
注:本文中的ViewArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论