Generated on Wed Nov 1 15:04:30 2006 for Gecode by doxygen 1.4.5

channel.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2006
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3512 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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 // STATISTICS: int-post