Generated on Thu Jul 6 07:06:42 2006 for Gecode by doxygen 1.4.7

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: 2005-10-27 21:01:30 +0200 (Thu, 27 Oct 2005) $ by $Author: schulte $
00010  *     $Revision: 2420 $
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       if (Val<IntView>::post(home,n,vi) == ES_FAILED)
00049         home->fail();
00050     } else {
00051       DomInfo<IntView>* di
00052         = DomInfo<IntView>::allocate(home,2*n);
00053       for (int i=n; i--; ) {
00054         di[i  ].init(x[i],n); 
00055         di[i+n].init(y[i],n);
00056       }
00057       if (Dom<IntView>::post(home,n,di) == ES_FAILED)
00058         home->fail();
00059     }
00060   }
00061 
00062 }
00063 
00064 // STATISTICS: int-post