Generated on Mon Aug 25 11:35:37 2008 for Gecode by doxygen 1.5.6

element.cc

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: 2008-02-06 20:23:59 +0100 (Wed, 06 Feb 2008) $ by $Author: schulte $
00011  *     $Revision: 6103 $
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, PropKind) {
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::Int<IntView,IntView>::post(home,cs,x0,x1)));
00054   }
00055 
00056   void
00057   element(Space* home, const IntArgs& c, IntVar x0, BoolVar x1,
00058           IntConLevel, PropKind) {
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,
00066                    (Element::Int<IntView,BoolView>::post(home,cs,x0,x1)));
00067   }
00068 
00069   void
00070   element(Space* home, const IntArgs& c, IntVar x0, int x1,
00071           IntConLevel, PropKind) {
00072     Limits::check(x1,"Int::element");
00073     if (home->failed()) return;
00074     Element::IntSharedArray cs(c.size());
00075     for (int i = c.size(); i--; ) {
00076       Limits::check(c[i],"Int::element");
00077       cs[i] = c[i];
00078     }
00079     ConstIntView cx1(x1);
00080     GECODE_ES_FAIL(home,(Element::Int<IntView,ConstIntView>
00081                          ::post(home,cs,x0,cx1)));
00082   }
00083 
00084   void
00085   element(Space* home, const IntVarArgs& c, IntVar x0, IntVar x1,
00086           IntConLevel icl, PropKind) {
00087     if (home->failed()) return;
00088     Element::IdxView<IntView>* iv = 
00089       Element::IdxView<IntView>::init(home,c);
00090     if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00091       GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,IntView>
00092                            ::post(home,iv,c.size(),x0,x1)));
00093     } else {
00094       GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,IntView>
00095                            ::post(home,iv,c.size(),x0,x1)));
00096     }
00097   }
00098 
00099   void
00100   element(Space* home, const IntVarArgs& c, IntVar x0, int x1,
00101           IntConLevel icl, PropKind) {
00102     Limits::check(x1,"Int::element");
00103     if (home->failed()) return;
00104     Element::IdxView<IntView>* iv = 
00105       Element::IdxView<IntView>::init(home,c);
00106     ConstIntView v1(x1);
00107     if ((icl == ICL_DOM) || (icl == ICL_DEF)) {
00108       GECODE_ES_FAIL(home,(Element::ViewDom<IntView,IntView,ConstIntView>
00109                            ::post(home,iv,c.size(),x0,v1)));
00110     } else {
00111       GECODE_ES_FAIL(home,(Element::ViewBnd<IntView,IntView,ConstIntView>
00112                            ::post(home,iv,c.size(),x0,v1)));
00113     }
00114   }
00115 
00116   void
00117   element(Space* home, const BoolVarArgs& c, IntVar x0, BoolVar x1,
00118           IntConLevel, PropKind) {
00119     if (home->failed()) return;
00120     Element::IdxView<BoolView>* iv = 
00121       Element::IdxView<BoolView>::init(home,c);
00122     GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,BoolView>
00123                          ::post(home,iv,c.size(),x0,x1)));
00124   }
00125 
00126   void
00127   element(Space* home, const BoolVarArgs& c, IntVar x0, int x1,
00128           IntConLevel, PropKind) {
00129     Limits::check(x1,"Int::element");
00130     if (home->failed()) return;
00131     Element::IdxView<BoolView>* iv = 
00132       Element::IdxView<BoolView>::init(home,c);
00133     ConstIntView v1(x1);
00134     GECODE_ES_FAIL(home,(Element::ViewBnd<BoolView,IntView,ConstIntView>
00135                          ::post(home,iv,c.size(),x0,v1)));
00136   }
00137 
00138   namespace {
00139     using namespace Int;
00140     GECODE_REGISTER2(Element::Int<IntView,ConstIntView>);
00141     GECODE_REGISTER2(Element::Int<IntView,BoolView>);
00142     GECODE_REGISTER2(Element::Int<IntView,IntView>);
00143 
00144     GECODE_REGISTER3(Element::ViewBnd<IntView,IntView,ConstIntView>);
00145     GECODE_REGISTER3(Element::ViewBnd<IntView,IntView,IntView>);
00146     GECODE_REGISTER3(Element::ViewBnd<BoolView,IntView,ConstIntView>);
00147     GECODE_REGISTER3(Element::ViewBnd<BoolView,IntView,BoolView>);
00148 
00149     GECODE_REGISTER3(Element::ViewDom<IntView,IntView,ConstIntView>);
00150     GECODE_REGISTER3(Element::ViewDom<IntView,IntView,IntView>);
00151   }
00152 
00153 }
00154 
00155 // STATISTICS: int-post
00156