Generated on Thu Mar 22 10:39:44 2012 for Gecode by doxygen 1.6.3

rel-op.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Contributing authors:
00007  *     Gabor Szokoli <szokoli@gecode.org>
00008  *
00009  *  Copyright:
00010  *     Guido Tack, 2004, 2005
00011  *
00012  *  Last modified:
00013  *     $Date: 2010-03-03 17:40:32 +0100 (Wed, 03 Mar 2010) $ by $Author: schulte $
00014  *     $Revision: 10365 $
00015  *
00016  *  This file is part of Gecode, the generic constraint
00017  *  development environment:
00018  *     http://www.gecode.org
00019  *
00020  *  Permission is hereby granted, free of charge, to any person obtaining
00021  *  a copy of this software and associated documentation files (the
00022  *  "Software"), to deal in the Software without restriction, including
00023  *  without limitation the rights to use, copy, modify, merge, publish,
00024  *  distribute, sublicense, and/or sell copies of the Software, and to
00025  *  permit persons to whom the Software is furnished to do so, subject to
00026  *  the following conditions:
00027  *
00028  *  The above copyright notice and this permission notice shall be
00029  *  included in all copies or substantial portions of the Software.
00030  *
00031  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00032  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00033  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00034  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00035  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00036  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00037  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00038  *
00039  */
00040 
00041 #include <gecode/set/rel-op.hh>
00042 
00043 namespace Gecode {
00044   using namespace Gecode::Set;
00045   using namespace Gecode::Set::Rel;
00046   using namespace Gecode::Set::RelOp;
00047 
00048   void
00049   rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y) {
00050     if (home.failed()) return;
00051     ViewArray<SetView> xa(home,x);
00052     switch (op) {
00053     case SOT_UNION:
00054       GECODE_ES_FAIL((RelOp::UnionN<SetView,SetView>::post(home, xa, y)));
00055       break;
00056     case SOT_DUNION:
00057       GECODE_ES_FAIL(
00058                      (RelOp::PartitionN<SetView,SetView>::post(home, xa, y)));
00059       break;
00060     case SOT_INTER:
00061       {
00062         GECODE_ES_FAIL(
00063                        (RelOp::IntersectionN<SetView,SetView>
00064                         ::post(home, xa, y)));
00065       }
00066       break;
00067     case SOT_MINUS:
00068       throw IllegalOperation("Set::rel");
00069       break;
00070     default:
00071       throw UnknownOperation("Set::rel");
00072     }
00073   }
00074 
00075   void
00076   rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y) {
00077     if (home.failed()) return;
00078     Set::Limits::check(z, "Set::rel");
00079     ViewArray<SetView> xa(home,x);
00080     switch (op) {
00081     case SOT_UNION:
00082       GECODE_ES_FAIL((RelOp::UnionN<SetView,SetView>::post(home, xa, z, y)));
00083       break;
00084     case SOT_DUNION:
00085       GECODE_ES_FAIL(
00086                      (RelOp::PartitionN<SetView,SetView>::post(home, xa, z, y)));
00087       break;
00088     case SOT_INTER:
00089       {
00090         GECODE_ES_FAIL(
00091                        (RelOp::IntersectionN<SetView,SetView>
00092                         ::post(home, xa, z, y)));
00093       }
00094       break;
00095     case SOT_MINUS:
00096       throw IllegalOperation("Set::rel");
00097       break;
00098     default:
00099       throw UnknownOperation("Set::rel");
00100     }
00101   }
00102 
00103 }
00104 
00105 // STATISTICS: set-post