Generated on Tue Apr 18 10:21:38 2017 for Gecode by doxygen 1.6.3

channel.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Denys Duchier <denys.duchier@univ-orleans.fr>
00005  *     Guido Tack <tack@gecode.org>
00006  *     Christian Schulte <schulte@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Denys Duchier, 2011
00010  *     Guido Tack, 2004
00011  *     Christian Schulte, 2004
00012  *
00013  *  Last modified:
00014  *     $Date: 2016-05-23 22:18:23 +0200 (Mon, 23 May 2016) $ by $Author: schulte $
00015  *     $Revision: 15073 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #include <gecode/set.hh>
00043 
00044 #include <gecode/set/channel.hh>
00045 
00046 namespace Gecode {
00047 
00048   void
00049   channelSorted(Home home, const IntVarArgs& x, SetVar y) {
00050     GECODE_POST;
00051     ViewArray<Int::IntView> xa(home,x);
00052     GECODE_ES_FAIL(Set::Channel::ChannelSorted<Set::SetView>::post(home,y,xa));
00053   }
00054 
00055   void
00056   channel(Home home, const IntVarArgs& x, const SetVarArgs& y) {
00057     GECODE_POST;
00058     ViewArray<Int::CachedView<Int::IntView> > xa(home,x.size());
00059     for (int i=x.size(); i--;)
00060       new (&xa[i]) Int::CachedView<Int::IntView>(x[i]);
00061     ViewArray<Set::CachedView<Set::SetView> > ya(home,y.size());
00062     for (int i=y.size(); i--;)
00063       new (&ya[i]) Set::CachedView<Set::SetView>(y[i]);
00064     GECODE_ES_FAIL((Set::Channel::ChannelInt<Set::SetView>::post(home,xa,ya)));
00065   }
00066 
00067   void
00068   channel(Home home, const BoolVarArgs& x, SetVar y) {
00069     GECODE_POST;
00070     ViewArray<Int::BoolView> xv(home,x);
00071     GECODE_ES_FAIL((Set::Channel::ChannelBool<Set::SetView>
00072                          ::post(home,xv,y)));
00073   }
00074 
00075   void
00076   channel(Home home, const SetVarArgs& x, const SetVarArgs& y)
00077   {
00078     GECODE_POST;
00079     ViewArray<Set::CachedView<Set::SetView> > xa(home, x.size());
00080     for (int i=x.size(); i--;)
00081       new (&xa[i]) Int::CachedView<Set::SetView>(x[i]);
00082     ViewArray<Set::CachedView<Set::SetView> > ya(home, y.size());
00083     for (int i=y.size(); i--;)
00084       new (&ya[i]) Set::CachedView<Set::SetView>(y[i]);
00085     GECODE_ES_FAIL((Set::Channel::ChannelSet<Set::SetView>::post(home,xa,ya)));
00086   }
00087 
00088 }
00089 
00090 // STATISTICS: set-post