Sha256: 260301b76c6ea608890033b50e1616ffea1ff1097d8483b17dccd5491e10ada1

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

/*
 *  Main authors:
 *     Guido Tack <tack@gecode.org>
 *     Christian Schulte <schulte@gecode.org>
 *     Gabor Szokoli <szokoli@gecode.org>
 *
 *  Copyright:
 *     Guido Tack, 2004
 *     Christian Schulte, 2004
 *     Gabor Szokoli, 2004
 *
 *  Last modified:
 *     $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
 *     $Revision: 3188 $
 *
 *  This file is part of Gecode, the generic constraint
 *  development environment:
 *     http://www.gecode.org
 *
 *  See the file "LICENSE" for information on usage and
 *  redistribution of this file, and for a
 *     DISCLAIMER OF ALL WARRANTIES.
 *
 */



#include "gecode/set.hh"
#include "gecode/int.hh"
#include "gecode/set/rel.hh"

namespace Gecode { namespace Set { namespace Int {

  forceinline
  Match::Match(Space* home, SetView y0, ViewArray< Gecode::Int::IntView >& ys)
    : Propagator(home), x0(y0), xs(ys) {
    x0.subscribe(home,this, PC_SET_ANY);
    xs.subscribe(home,this, Gecode::Int::PC_INT_BND);
  }

  forceinline
  Match::Match(Space* home, bool share, Match& p)
    : Propagator(home,share,p) {
    x0.update(home,share,p.x0);
    xs.update(home,share,p.xs);
  }

  forceinline ExecStatus
  Match::post(Space* home, SetView x0, ViewArray<Gecode::Int::IntView>& xs) {
    unsigned int xs_size = xs.size();
    GECODE_ME_CHECK(x0.cardMin(home,xs_size));
    GECODE_ME_CHECK(x0.cardMax(home,xs_size));
    if (xs_size==1) {
      SingletonView sv(xs[0]);
      GECODE_ES_CHECK((Rel::Eq<SetView,
		       SingletonView>::post(home,x0, sv)));
    } else {
      // Sharing in xs is handled correctly in the propagator:
      // if two views in xs are shared, this leads to failure.
      (void) new (home) Match(home,x0,xs);
    }
    return ES_OK;
  }

}}}

// STATISTICS: set-prop

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gecoder-with-gecode-0.7.1 ext/gecode-1.3.1/gecode/set/int/match.icc