~ubuntu-branches/ubuntu/natty/gecode/natty

« back to all changes in this revision

Viewing changes to set/distinct/distinct.icc

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2005-12-24 07:51:25 UTC
  • Revision ID: james.westby@ubuntu.com-20051224075125-klkiqofvbfvusfvt
Tags: upstream-1.0.0.dfsg.1
ImportĀ upstreamĀ versionĀ 1.0.0.dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Main authors:
 
3
 *     Guido Tack <tack@gecode.org>
 
4
 *
 
5
 *  Copyright:
 
6
 *     Guido Tack, 2004
 
7
 *
 
8
 *  Last modified:
 
9
 *     $Date: 2005-11-24 18:03:01 +0100 (Thu, 24 Nov 2005) $ by $Author: tack $
 
10
 *     $Revision: 2639 $
 
11
 *
 
12
 *  This file is part of Gecode, the generic constraint
 
13
 *  development environment:
 
14
 *     http://www.gecode.org
 
15
 *
 
16
 *  See the file "LICENSE" for information on usage and
 
17
 *  redistribution of this file, and for a
 
18
 *     DISCLAIMER OF ALL WARRANTIES.
 
19
 *
 
20
 */
 
21
 
 
22
namespace Gecode { namespace Set { namespace Distinct {
 
23
 
 
24
  /*
 
25
   * n-ary distinct with fixed cardinalities propagator
 
26
   *
 
27
   */
 
28
 
 
29
  forceinline
 
30
  Distinct::Distinct(Space* home, ViewArray<SetView>& x, unsigned int _c)
 
31
    : NaryPropagator<SetView, PC_SET_ANY>(home,x), bin(10), c(_c) {}
 
32
 
 
33
  forceinline
 
34
  Distinct::Distinct(Space* home, bool share, Distinct& p)
 
35
    : NaryPropagator<SetView, PC_SET_ANY>(home,share,p), bin(0), c(p.c) {
 
36
    bin.update(share, p.bin);
 
37
  }
 
38
 
 
39
  forceinline ExecStatus
 
40
  Distinct::post(Space* home, ViewArray<SetView> x, unsigned int c) {
 
41
    for (int i=x.size(); i--;) {
 
42
      GECODE_ES_CHECK(x[i].cardMin(home, c));
 
43
      GECODE_ES_CHECK(x[i].cardMax(home, c));
 
44
    }
 
45
 
 
46
    (void) new (home) Distinct(home,x,c);
 
47
    return ES_OK;
 
48
  }
 
49
 
 
50
}}}
 
51
 
 
52
// STATISTICS: set-prop