Generated on Mon Jul 6 18:09:08 2009 for Gecode by doxygen 1.5.9

element.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2004
00008  *
00009  *  Last modified:
00010  *     $Date: 2009-02-04 13:17:26 +0100 (Wed, 04 Feb 2009) $ by $Author: schulte $
00011  *     $Revision: 8137 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include <gecode/int/element.hh>
00039 
00040 namespace Gecode {
00041 
00042   using namespace Int;
00043 
00044   void
00045   element(Space& home, const IntArgs& c, IntVar x0, IntVar x1,
00046           IntConLevel) {
00047     if (home.failed()) return;
00048     Element::IntSharedArray cs(c.size());
00049     for (int i = c.size(); i--; ) {
00050       Limits::check(c[i],"Int::element");
00051       cs[i] = c[i];
00052     }
00053     GECODE_ES_FAIL(home,(Element::post_int<IntView,IntView>(home,cs,x0,x1)));
00054   }
00055 
00056   void
00057   element(Space& home, const IntArgs& c, IntVar x0, BoolVar x1,
00058           IntConLevel) {
00059     if (home.failed()) return;
00060     Element::IntSharedArray cs(c.size());
00061     for (int i = c.size(); i--; ) {
00062       Limits::check(c[i],"Int::element");
00063       cs[i] = c[i];
00064     }
00065     GECODE_ES_FAIL(home,(Element::post_int<IntView,BoolView>(home,cs,x0,x1)));
00066   }
00067 
00068   void
00069   element(Space& home, const IntArgs& c, IntVar x0, int x1,
00070           IntConLevel) {
00071     Limits::check(x1,"Int::element");
00072     if (home.failed()) return;
00073     Element::IntSharedArray cs(c.size());
00074     for (int i = c.size(); i--; ) {
00075       Limits::check(c[i],"Int::element");
00076       cs[i] = c[i];
00077     }
00078     ConstIntView cx1(x1);
00079     GECODE_ES_FAIL(home,
00080                    (Element::post_int<IntView,ConstIntView>(home,cs,x0,cx1)));
00081   }
00082 
00083   void
00084   element(Space& home, const IntVarArgs& c, IntVar x0, IntVar x1,
00085           IntConLevel icl) {
00086     if (home.failed()) return;
00087     Element::IdxViewArray<IntView> iv(home,c);
00088     if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00089       GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,IntView>
00090                            ::post(home,iv,x0,x1)));
00091     } else {
00092       GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,IntView>
00093                            ::post(home,iv,x0,x1)));
00094     }
00095   }
00096 
00097   void
00098   element(Space& home, const IntVarArgs& c, IntVar x0, int x1,
00099           IntConLevel icl) {
00100     Limits::check(x1,"Int::element");
00101     if (home.failed()) return;
00102     Element::IdxViewArray<IntView> iv(home,c);
00103     ConstIntView v1(x1);
00104     if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00105       GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,ConstIntView>
00106                            ::post(home,iv,x0,v1)));
00107     } else {
00108       GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,ConstIntView>
00109                            ::post(home,iv,x0,v1)));
00110     }
00111   }
00112 
00113   void
00114   element(Space& home, const BoolVarArgs& c, IntVar x0, BoolVar x1,
00115           IntConLevel) {
00116     if (home.failed()) return;
00117     Element::IdxViewArray<BoolView> iv(home,c);
00118     GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,BoolView>
00119                          ::post(home,iv,x0,x1)));
00120   }
00121 
00122   void
00123   element(Space& home, const BoolVarArgs& c, IntVar x0, int x1,
00124           IntConLevel) {
00125     Limits::check(x1,"Int::element");
00126     if (home.failed()) return;
00127     Element::IdxViewArray<BoolView> iv(home,c);
00128     ConstIntView v1(x1);
00129     GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,ConstIntView>
00130                          ::post(home,iv,x0,v1)));
00131   }
00132 
00133 }
00134 
00135 // STATISTICS: int-post