Sha256: f7017f923aaba549864f5a09cac330fc5011b28dcf868744ea6ee54f3c975ae9

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

/*
 *  Main authors:
 *     Christian Schulte <schulte@gecode.org>
 *     Gabor Szokoli <szokoli@gecode.org>
 *
 *  Copyright:
 *     Christian Schulte, 2002
 *     Gabor Szokoli, 2003
 *
 *  Last modified:
 *     $Date: 2006-08-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
 *     $Revision: 3512 $
 *
 *  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/int/distinct.hh"

namespace Gecode {

  using namespace Int;

  void
  distinct(Space* home, const IntVarArgs& x, IntConLevel icl) {
    if (x.same())
      throw ArgumentSame("Int::distinct");
    if (home->failed()) return;
    ViewArray<IntView> xv(home,x);
    switch (icl) {
    case ICL_BND:
      GECODE_ES_FAIL(home,Distinct::Bnd<IntView>::post(home,xv));
      break;
    case ICL_DOM:
      GECODE_ES_FAIL(home,Distinct::Dom<IntView>::post(home,xv));
      break;
    default:
      GECODE_ES_FAIL(home,Distinct::Val<IntView>::post(home,xv));
    }
  }

  void
  distinct(Space* home, const IntArgs& c, const IntVarArgs& x,
	   IntConLevel icl) {
    if (x.same())
      throw ArgumentSame("Int::distinct");
    if (c.size() != x.size())
      throw ArgumentSizeMismatch("Int::distinct");
    if (home->failed()) return;
    ViewArray<OffsetView> cx(home,x.size());
    for (int i = c.size(); i--; )
      if ((c[i] < Limits::Int::int_min) || (c[i] > Limits::Int::int_max))
	throw NumericalOverflow("Int::distinct");
      else
	cx[i].init(x[i],c[i]);
    switch (icl) {
    case ICL_BND:
      GECODE_ES_FAIL(home,Distinct::Bnd<OffsetView>::post(home,cx));
      break;
    case ICL_DOM:
      GECODE_ES_FAIL(home,Distinct::Dom<OffsetView>::post(home,cx));
      break;
    default:
      GECODE_ES_FAIL(home,Distinct::Val<OffsetView>::post(home,cx));
    }
  }

}

// STATISTICS: int-post

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gecoder-with-gecode-0.7.1 ext/gecode-1.3.1/gecode/int/distinct.cc