main page
modules
namespaces
classes
files
Gecode home
Generated on Thu Mar 13 2014 04:39:34 for Gecode by
doxygen
1.8.1.2
gecode
int
view
neg-bool.hpp
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, 2008
8
*
9
* Last modified:
10
* $Date: 2010-06-29 18:39:13 +1000 (Tue, 29 Jun 2010) $ by $Author: schulte $
11
* $Revision: 11118 $
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
namespace
Gecode {
namespace
Int {
39
40
/*
41
* Negated Boolean views
42
*
43
*/
44
45
/*
46
* Constructors and initialization
47
*
48
*/
49
forceinline
50
NegBoolView::NegBoolView
(
void
) {}
51
forceinline
52
NegBoolView::NegBoolView
(
const
BoolView
& y)
53
:
DerivedView
<
BoolView
>(y) {}
54
55
56
/*
57
* Boolean domain tests
58
*
59
*/
60
forceinline
BoolStatus
61
NegBoolView::status
(
void
)
const
{
62
return
x
.
status
();
63
}
64
forceinline
bool
65
NegBoolView::zero
(
void
)
const
{
66
return
x
.
one
();
67
}
68
forceinline
bool
69
NegBoolView::one
(
void
)
const
{
70
return
x
.
zero
();
71
}
72
forceinline
bool
73
NegBoolView::none
(
void
)
const
{
74
return
x
.
none
();
75
}
76
77
78
/*
79
* Boolean assignment operations
80
*
81
*/
82
forceinline
ModEvent
83
NegBoolView::zero_none
(
Space
& home) {
84
return
x
.
one_none
(home);
85
}
86
forceinline
ModEvent
87
NegBoolView::one_none
(
Space
& home) {
88
return
x
.
zero_none
(home);
89
}
90
91
forceinline
ModEvent
92
NegBoolView::zero
(
Space
& home) {
93
return
x
.
one
(home);
94
}
95
forceinline
ModEvent
96
NegBoolView::one
(
Space
& home) {
97
return
x
.
zero
(home);
98
}
99
100
101
/*
102
* Value access
103
*
104
*/
105
forceinline
int
106
NegBoolView::min
(
void
)
const
{
107
return
x
.
max
();
108
}
109
forceinline
int
110
NegBoolView::max
(
void
)
const
{
111
return
x
.
min
();
112
}
113
forceinline
int
114
NegBoolView::val
(
void
)
const
{
115
return
1-
x
.
val
();
116
}
117
118
119
/*
120
* Delta information for advisors
121
*
122
*/
123
forceinline
int
124
NegBoolView::min
(
const
Delta
&
d
)
const
{
125
return
x
.
max
(d);
126
}
127
forceinline
int
128
NegBoolView::max
(
const
Delta
&
d
)
const
{
129
return
x
.
min
(d);
130
}
131
forceinline
bool
132
NegBoolView::any
(
const
Delta
&
d
)
const
{
133
return
x
.
any
(d);
134
}
135
forceinline
bool
136
NegBoolView::zero
(
const
Delta
&
d
) {
137
return
BoolView::one
(d);
138
}
139
forceinline
bool
140
NegBoolView::one
(
const
Delta
&
d
) {
141
return
BoolView::zero
(d);
142
}
143
144
149
template
<>
150
class
ViewRanges
<
NegBoolView
> :
public
Iter::Ranges::Singleton
{
151
public
:
153
154
155
ViewRanges
(
void
);
157
ViewRanges
(
const
NegBoolView
& x);
159
void
init
(
const
NegBoolView
& x);
161
};
162
163
forceinline
164
ViewRanges<NegBoolView>::ViewRanges
(
void
) {}
165
166
forceinline
167
ViewRanges<NegBoolView>::ViewRanges
(
const
NegBoolView
& x)
168
: Iter::Ranges::Singleton(x.
min
(),x.
max
()) {}
169
170
forceinline
void
171
ViewRanges<NegBoolView>::init
(
const
NegBoolView
& x) {
172
Iter::Ranges::Singleton::init
(x.
min
(),x.
max
());
173
}
174
175
}}
176
177
// STATISTICS: int-var