channel.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 #include "gecode/set.hh"
00029 #include "gecode/int.hh"
00030
00031 namespace Gecode { namespace Set { namespace Int {
00032
00033 forceinline
00034 Channel::Channel(Space* home,
00035 ViewArray< Gecode::Int::IntView >& xs0,
00036 ViewArray< SetView >& ys0)
00037 : Propagator(home), xs(xs0), ys(ys0) {
00038 xs.subscribe(home,this, Gecode::Int::PC_INT_DOM);
00039 ys.subscribe(home,this, PC_SET_ANY);
00040 }
00041
00042 forceinline
00043 Channel::Channel(Space* home, bool share,
00044 Channel& p)
00045 : Propagator(home,share,p) {
00046 xs.update(home,share,p.xs);
00047 ys.update(home,share,p.ys);
00048 }
00049
00050 forceinline ExecStatus
00051 Channel::post(Space* home, ViewArray<Gecode::Int::IntView>& xs,
00052 ViewArray<SetView>& ys) {
00053
00054
00055
00056 unsigned int xssize = xs.size();
00057 for (int i=ys.size(); i--;) {
00058 GECODE_ME_CHECK(ys[i].exclude(home, xssize, Limits::Set::int_max));
00059 GECODE_ME_CHECK(ys[i].exclude(home, Limits::Set::int_min, -1));
00060 }
00061 unsigned int yssize = ys.size();
00062 if (yssize > static_cast<unsigned int>(Limits::Int::int_max))
00063 return ES_FAILED;
00064 for (int i=xs.size(); i--;) {
00065 GECODE_ME_CHECK(xs[i].gq(home, 0));
00066 GECODE_ME_CHECK(xs[i].le(home, static_cast<int>(yssize)));
00067 }
00068
00069 (void) new (home) Channel(home,xs,ys);
00070 return ES_OK;
00071 }
00072
00073 }}}
00074
00075