main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:29 for Gecode by
doxygen
1.8.4
gecode
int
member.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Copyright:
7
* Christian Schulte, 2011
8
*
9
* Last modified:
10
* $Date: 2011-11-18 16:02:48 +0100 (Fri, 18 Nov 2011) $ by $Author: schulte $
11
* $Revision: 12472 $
12
*
13
* This file is part of Gecode, the generic constraint
14
* development environment:
15
* http://www.gecode.org
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining
18
* a copy of this software and associated documentation files (the
19
* "Software"), to deal in the Software without restriction, including
20
* without limitation the rights to use, copy, modify, merge, publish,
21
* distribute, sublicense, and/or sell copies of the Software, and to
22
* permit persons to whom the Software is furnished to do so, subject to
23
* the following conditions:
24
*
25
* The above copyright notice and this permission notice shall be
26
* included in all copies or substantial portions of the Software.
27
*
28
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
*
36
*/
37
38
#include <
gecode/int/member.hh
>
39
40
namespace
Gecode {
41
42
void
43
member
(
Home
home,
const
IntVarArgs
&
x
,
IntVar
y,
44
IntConLevel
) {
45
using namespace
Int;
46
if
(home.
failed
())
return
;
47
48
ViewArray<IntView>
xv(home,x);
49
GECODE_ES_FAIL
(
Member::Prop<IntView>::post
(home,xv,y));
50
}
51
52
void
53
member
(
Home
home,
const
BoolVarArgs
&
x
,
BoolVar
y,
54
IntConLevel
) {
55
using namespace
Int;
56
if
(home.
failed
())
return
;
57
58
ViewArray<BoolView>
xv(home,x);
59
GECODE_ES_FAIL
(
Member::Prop<BoolView>::post
(home,xv,y));
60
}
61
62
void
63
member
(
Home
home,
const
IntVarArgs
&
x
,
IntVar
y,
Reify
r
,
64
IntConLevel
) {
65
using namespace
Int;
66
if
(home.
failed
())
return
;
67
68
ViewArray<IntView>
xv(home,x);
69
70
switch
(r.
mode
()) {
71
case
RM_EQV
:
72
GECODE_ES_FAIL
((
Member::ReProp<IntView,RM_EQV>
73
::
post
(home,xv,y,r.
var
())));
74
break
;
75
case
RM_IMP
:
76
GECODE_ES_FAIL
((
Member::ReProp<IntView,RM_IMP>
77
::
post
(home,xv,y,r.
var
())));
78
break
;
79
case
RM_PMI
:
80
GECODE_ES_FAIL
((
Member::ReProp<IntView,RM_PMI>
81
::
post
(home,xv,y,r.
var
())));
82
break
;
83
default
:
throw
UnknownReifyMode
(
"Int::member"
);
84
}
85
}
86
87
void
88
member
(
Home
home,
const
BoolVarArgs
&
x
,
BoolVar
y,
Reify
r
,
89
IntConLevel
) {
90
using namespace
Int;
91
if
(home.
failed
())
return
;
92
93
ViewArray<BoolView>
xv(home,x);
94
95
switch
(r.
mode
()) {
96
case
RM_EQV
:
97
GECODE_ES_FAIL
((
Member::ReProp<BoolView,RM_EQV>
98
::
post
(home,xv,y,r.
var
())));
99
break
;
100
case
RM_IMP
:
101
GECODE_ES_FAIL
((
Member::ReProp<BoolView,RM_IMP>
102
::
post
(home,xv,y,r.
var
())));
103
break
;
104
case
RM_PMI
:
105
GECODE_ES_FAIL
((
Member::ReProp<BoolView,RM_PMI>
106
::
post
(home,xv,y,r.
var
())));
107
break
;
108
default
:
throw
UnknownReifyMode
(
"Int::member"
);
109
}
110
111
}
112
113
}
114
115
// STATISTICS: int-post
116