channel.cpp
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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <gecode/set.hh>
00043
00044 #include <gecode/set/channel.hh>
00045
00046 namespace Gecode {
00047
00048 void
00049 channelSorted(Home home, const IntVarArgs& x, SetVar y) {
00050 if (home.failed()) return;
00051 ViewArray<Int::IntView> xa(home,x);
00052 GECODE_ES_FAIL(Set::Channel::ChannelSorted<Set::SetView>::post(home,y,xa));
00053 }
00054
00055 void
00056 channel(Home home, const IntVarArgs& x, const SetVarArgs& y) {
00057 if (home.failed()) return;
00058 ViewArray<Int::CachedView<Int::IntView> > xa(home,x.size());
00059 for (int i=x.size(); i--;)
00060 new (&xa[i]) Int::CachedView<Int::IntView>(x[i]);
00061 ViewArray<Set::CachedView<Set::SetView> > ya(home,y.size());
00062 for (int i=y.size(); i--;)
00063 new (&ya[i]) Set::CachedView<Set::SetView>(y[i]);
00064 GECODE_ES_FAIL((Set::Channel::ChannelInt<Set::SetView>::post(home,xa,ya)));
00065 }
00066
00067 void
00068 channel(Home home, const BoolVarArgs& x, SetVar y) {
00069 if (home.failed()) return;
00070 ViewArray<Int::BoolView> xv(home,x);
00071 GECODE_ES_FAIL((Set::Channel::ChannelBool<Set::SetView>
00072 ::post(home,xv,y)));
00073 }
00074
00075 void
00076 channel(Home home, const SetVarArgs& x, const SetVarArgs& y)
00077 {
00078 if (home.failed()) return;
00079 ViewArray<Set::CachedView<Set::SetView> > xa(home, x.size());
00080 for (int i=x.size(); i--;)
00081 new (&xa[i]) Int::CachedView<Set::SetView>(x[i]);
00082 ViewArray<Set::CachedView<Set::SetView> > ya(home, y.size());
00083 for (int i=y.size(); i--;)
00084 new (&ya[i]) Set::CachedView<Set::SetView>(y[i]);
00085 GECODE_ES_FAIL((Set::Channel::ChannelSet<Set::SetView>::post(home,xa,ya)));
00086 }
00087
00088 }
00089
00090