common.icc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 namespace Gecode { namespace Set { namespace Sequence {
00029
00030 forceinline
00031 ExecStatus propagateSeq(Space* home,
00032 bool& modified, ViewArray<SetView>& x) {
00033
00034 int lastElem = x.size()-1;
00035 int cur_max = BndSet::MAX_OF_EMPTY;
00036 int cur_min = BndSet::MIN_OF_EMPTY;
00037
00038 for (int i=0; i<lastElem; i++) {
00039 if (x[i].glbSize() > 0) {
00040 int glbMax = x[i].glbMax();
00041 cur_max = std::max(cur_max, glbMax);
00042 }
00043 if (cur_max>=Limits::Set::int_min)
00044 GECODE_ME_CHECK_B(modified,
00045 x[i+1].exclude(home, Limits::Set::int_min, cur_max));
00046
00047 if (x[lastElem-i].lubSize() > 0) {
00048 int glbMin = x[lastElem-i].glbMin();
00049 cur_min = std::min(cur_min, glbMin);
00050 }
00051 if (Limits::Set::int_max>=cur_min)
00052 GECODE_ME_CHECK_B(modified,
00053 x[lastElem-i-1].exclude(home, cur_min,
00054 Limits::Set::int_max));
00055 }
00056 return ES_FIX;
00057 }
00058
00059 forceinline
00060 ExecStatus propagateSeqUnion(Space* home,
00061 bool& modified, ViewArray<SetView>& x, SetView& y) {
00062
00063 GECODE_AUTOARRAY(GlbRanges<SetView>, XLBs,x.size());
00064 for (int i=x.size(); i--; ){
00065 GlbRanges<SetView> lb(x[i]);
00066 XLBs[i]=lb;
00067 }
00068 Iter::Ranges::NaryAppend<GlbRanges<SetView> > u(XLBs,x.size());
00069 GECODE_ME_CHECK_B(modified, y.includeI(home,u));
00070 return ES_FIX;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 forceinline void eliminateFromArrayPreservingOrder(ViewArray<SetView>& x,
00084 unsigned int n) {
00085 assert(n < (unsigned int)x.size());
00086 SetView temp = x[n];
00087 for (int i=n; i < x.size()-1;i++) {
00088 x[i]=x[i+1];
00089 }
00090 x[x.size()-1] = temp;
00091 x.move_lst(x.size()-1);
00092 }
00093
00094 }}}
00095
00096