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

« back to all changes in this revision

Viewing changes to int/bool.cc

  • 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
 *     Christian Schulte <schulte@gecode.org>
 
4
 *
 
5
 *  Copyright:
 
6
 *     Christian Schulte, 2002
 
7
 *
 
8
 *  Last modified:
 
9
 *     $Date: 2005-10-27 18:45:00 +0200 (Thu, 27 Oct 2005) $ by $Author: schulte $
 
10
 *     $Revision: 2419 $
 
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
#include "int/bool.hh"
 
23
 
 
24
namespace Gecode {
 
25
 
 
26
  using namespace Int;
 
27
 
 
28
  void
 
29
  bool_not(Space* home, BoolVar b0, BoolVar b1, IntConLevel) {
 
30
    if (home->failed()) return;
 
31
    NegBoolView n1(b1);
 
32
    if (Bool::Eq<BoolView,NegBoolView>::post(home,b0,n1) == ES_FAILED)
 
33
      home->fail();
 
34
  }
 
35
  void
 
36
  bool_eq(Space* home, BoolVar b0, BoolVar b1, IntConLevel) {
 
37
    if (home->failed()) return;
 
38
    if (Bool::Eq<BoolView,BoolView>::post(home,b0,b1) == ES_FAILED)
 
39
      home->fail();
 
40
  }
 
41
  void
 
42
  bool_and(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
 
43
    if (home->failed()) return;
 
44
    if (Bool::And<BoolView,BoolView,BoolView>::post(home,b0,b1,b2)
 
45
        == ES_FAILED)
 
46
      home->fail();
 
47
  }
 
48
  void
 
49
  bool_or(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
 
50
    if (home->failed()) return;
 
51
    NegBoolView n0(b0); NegBoolView n1(b1); NegBoolView n2(b2);
 
52
    if (Bool::And<NegBoolView,NegBoolView,NegBoolView>::post(home,n0,n1,n2)
 
53
        == ES_FAILED)
 
54
      home->fail();
 
55
  }
 
56
  void
 
57
  bool_imp(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
 
58
    if (home->failed()) return;
 
59
    NegBoolView n1(b1); NegBoolView n2(b2);
 
60
    if (Bool::And<BoolView,NegBoolView,NegBoolView>::post(home,b0,n1,n2)
 
61
        == ES_FAILED)
 
62
      home->fail();
 
63
  }
 
64
  void
 
65
  bool_eqv(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
 
66
    if (home->failed()) return;
 
67
    if (Bool::Eqv<BoolView,BoolView,BoolView>::post(home,b0,b1,b2)
 
68
        == ES_FAILED)
 
69
      home->fail();
 
70
  }
 
71
  void
 
72
  bool_xor(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
 
73
    if (home->failed()) return;
 
74
    NegBoolView n2(b2);
 
75
    if (Bool::Eqv<BoolView,BoolView,NegBoolView>::post(home,b0,b1,n2)
 
76
        == ES_FAILED)
 
77
      home->fail();
 
78
  }
 
79
  void
 
80
  bool_and(Space* home, const BoolVarArgs& b, BoolVar c, IntConLevel) {
 
81
    if (home->failed()) return;
 
82
    ViewArray<BoolView> x(home,b);
 
83
    GECODE_ES_FAIL(home,Bool::NaryAnd<BoolView>::post(home,x,c));
 
84
  }
 
85
  void
 
86
  bool_or(Space* home, const BoolVarArgs& b, BoolVar c, IntConLevel) {
 
87
    if (home->failed()) return;
 
88
    ViewArray<NegBoolView> x(home,b.size());
 
89
    for (int i=b.size(); i--; ) {
 
90
      NegBoolView nb(b[i]); x[i]=nb;
 
91
    }
 
92
    NegBoolView nc(c);
 
93
    GECODE_ES_FAIL(home,Bool::NaryAnd<NegBoolView>::post(home,x,nc));
 
94
  }
 
95
 
 
96
}
 
97
 
 
98
 
 
99
// STATISTICS: int-post
 
100