3
* Christian Schulte <schulte@gecode.org>
6
* Christian Schulte, 2002
9
* $Date: 2005-11-04 13:56:04 +0100 (Fri, 04 Nov 2005) $ by $Author: schulte $
12
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
16
* See the file "LICENSE" for information on usage and
17
* redistribution of this file, and for a
18
* DISCLAIMER OF ALL WARRANTIES.
22
#include "int/count.hh"
28
#define CREATE(VY,VZ,C) \
29
if (icl == ICL_BND) { \
30
if (C<IntView,VY,VZ,Count::RelEqBnd<IntView>,true>::post(home,x,y,z,c) \
34
if (C<IntView,VY,VZ,Count::RelEqDom<IntView>,true>::post(home,x,y,z,c) \
40
count(Space* home, const IntVarArgs& xa, int yn,
41
IntRelType r, int zn, IntConLevel icl) {
42
if (home->failed()) return;
43
ViewArray<IntView> x(home,xa);
49
CREATE(ConstIntView,ConstIntView,Count::Eq); break;
51
CREATE(ConstIntView,ConstIntView,Count::Nq); break;
53
c = 1; // Fall through
55
CREATE(ConstIntView,ConstIntView,Count::Lq); break;
57
c = -1; // Fall through
59
CREATE(ConstIntView,ConstIntView,Count::Gq); break;
61
throw UnknownRelation("Int::count");
66
count(Space* home, const IntVarArgs& xa, int yn,
67
IntRelType r, IntVar z, IntConLevel icl) {
68
if (home->failed()) return;
69
ViewArray<IntView> x(home,xa);
74
CREATE(ConstIntView,IntView,Count::Eq); break;
76
CREATE(ConstIntView,IntView,Count::Nq); break;
78
c = 1; // Fall through
80
CREATE(ConstIntView,IntView,Count::Lq); break;
82
c = -1; // Fall through
84
CREATE(ConstIntView,IntView,Count::Gq); break;
86
throw UnknownRelation("Int::count");
91
count(Space* home, const IntVarArgs& xa, IntVar y,
92
IntRelType r, int zn, IntConLevel icl) {
93
if (home->failed()) return;
94
ViewArray<IntView> x(home,xa);
99
CREATE(IntView,ConstIntView,Count::Eq); break;
101
CREATE(IntView,ConstIntView,Count::Nq); break;
103
c = 1; // Fall through
105
CREATE(IntView,ConstIntView,Count::Lq); break;
107
c = -1; // Fall through
109
CREATE(IntView,ConstIntView,Count::Gq); break;
111
throw UnknownRelation("Int::count");
116
count(Space* home, const IntVarArgs& xa, IntVar y,
117
IntRelType r, IntVar z, IntConLevel icl) {
118
if (home->failed()) return;
119
ViewArray<IntView> x(home,xa);
123
CREATE(IntView,IntView,Count::Eq); break;
125
CREATE(IntView,IntView,Count::Nq); break;
127
c = 1; // Fall through
129
CREATE(IntView,IntView,Count::Lq); break;
131
c = -1; // Fall through
133
CREATE(IntView,IntView,Count::Gq); break;
135
throw UnknownRelation("Int::count");
141
// STATISTICS: int-post