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

element.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
00010  *     $Revision: 3188 $
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/element.hh"
00023 
00024 namespace Gecode {
00025 
00026   using namespace Int;
00027 
00028   void
00029   element(Space* home, const IntArgs& c, IntVar x0, IntVar x1,
00030           IntConLevel) {
00031     if (home->failed()) return;
00032     Element::IntSharedArray cs(c.size());
00033     for (int i = c.size(); i--; )
00034       if ((c[i] < Limits::Int::int_min) || (c[i] > Limits::Int::int_max))
00035         throw NumericalOverflow("Int::element");
00036       else
00037         cs[i] = c[i];
00038     if (Element::Int<IntView,IntView>::post(home,cs,x0,x1) == ES_FAILED)
00039       home->fail();
00040   }
00041 
00042   void
00043   element(Space* home, const IntVarArgs& c, IntVar x0, IntVar x1,
00044           IntConLevel icl) {
00045     if (home->failed()) return;
00046     Element::IdxView<IntView>* iv = Element::IdxView<IntView>::init(home,c);
00047     if (icl == ICL_BND) {
00048       if (Element::ViewBnd<IntView,IntView>::post(home,iv,c.size(),x0,x1) 
00049           == ES_FAILED)
00050         home->fail();
00051     } else {
00052       if (Element::ViewDom<IntView,IntView>::post(home,iv,c.size(),x0,x1) 
00053           == ES_FAILED)
00054         home->fail();
00055     }
00056   }
00057 
00058 }
00059 
00060 
00061 // STATISTICS: int-post
00062