channel.cc
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 #include "gecode/int/channel.hh"
00023
00024 namespace Gecode {
00025
00026 using namespace Int;
00027
00028 void
00029 channel(Space* home, const IntVarArgs& x, const IntVarArgs& y,
00030 IntConLevel icl) {
00031 using namespace Channel;
00032 int n = x.size();
00033 if (n != y.size())
00034 throw ArgumentSizeMismatch("Int::channel");
00035 if (x.same(y))
00036 throw ArgumentSame("Int::channel");
00037 if (home->failed()) return;
00038 if (n == 0)
00039 return;
00040
00041 if (icl == ICL_VAL) {
00042 ValInfo<IntView>* vi
00043 = ValInfo<IntView>::allocate(home,2*n);
00044 for (int i=n; i--; ) {
00045 vi[i ].init(x[i],n);
00046 vi[i+n].init(y[i],n);
00047 }
00048 GECODE_ES_FAIL(home,Val<IntView>::post(home,n,vi));
00049 } else {
00050 DomInfo<IntView>* di
00051 = DomInfo<IntView>::allocate(home,2*n);
00052 for (int i=n; i--; ) {
00053 di[i ].init(x[i],n);
00054 di[i+n].init(y[i],n);
00055 }
00056 GECODE_ES_FAIL(home,Dom<IntView>::post(home,n,di));
00057 }
00058 }
00059
00060 }
00061
00062