Generated on Wed Nov 1 15:04:44 2006 for Gecode by doxygen 1.4.5

match.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Gabor Szokoli <szokoli@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Guido Tack, 2004
00009  *     Christian Schulte, 2004
00010  *     Gabor Szokoli, 2004
00011  *
00012  *  Last modified:
00013  *     $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
00014  *     $Revision: 3188 $
00015  *
00016  *  This file is part of Gecode, the generic constraint
00017  *  development environment:
00018  *     http://www.gecode.org
00019  *
00020  *  See the file "LICENSE" for information on usage and
00021  *  redistribution of this file, and for a
00022  *     DISCLAIMER OF ALL WARRANTIES.
00023  *
00024  */
00025 
00026 
00027 
00028 #include "gecode/set.hh"
00029 #include "gecode/int.hh"
00030 #include "gecode/set/rel.hh"
00031 
00032 namespace Gecode { namespace Set { namespace Int {
00033 
00034   forceinline
00035   Match::Match(Space* home, SetView y0, ViewArray< Gecode::Int::IntView >& ys)
00036     : Propagator(home), x0(y0), xs(ys) {
00037     x0.subscribe(home,this, PC_SET_ANY);
00038     xs.subscribe(home,this, Gecode::Int::PC_INT_BND);
00039   }
00040 
00041   forceinline
00042   Match::Match(Space* home, bool share, Match& p)
00043     : Propagator(home,share,p) {
00044     x0.update(home,share,p.x0);
00045     xs.update(home,share,p.xs);
00046   }
00047 
00048   forceinline ExecStatus
00049   Match::post(Space* home, SetView x0, ViewArray<Gecode::Int::IntView>& xs) {
00050     unsigned int xs_size = xs.size();
00051     GECODE_ME_CHECK(x0.cardMin(home,xs_size));
00052     GECODE_ME_CHECK(x0.cardMax(home,xs_size));
00053     if (xs_size==1) {
00054       SingletonView sv(xs[0]);
00055       GECODE_ES_CHECK((Rel::Eq<SetView,
00056                        SingletonView>::post(home,x0, sv)));
00057     } else {
00058       // Sharing in xs is handled correctly in the propagator:
00059       // if two views in xs are shared, this leads to failure.
00060       (void) new (home) Match(home,x0,xs);
00061     }
00062     return ES_OK;
00063   }
00064 
00065 }}}
00066 
00067 // STATISTICS: set-prop