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
sequence
set-op.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, 2009
8
*
9
* Last modified:
10
* $Date: 2010-03-03 16:38:41 +0100 (Wed, 03 Mar 2010) $
11
* $Revision: 10359 $
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 {
namespace
Sequence {
39
41
enum
TakesStatus
{
42
TS_NO
,
43
TS_YES
,
44
TS_MAYBE
45
};
46
48
template
<
class
View>
49
forceinline
TakesStatus
50
takes
(
const
View&
x
,
int
s) {
51
if
(x.in(s))
52
return
x.assigned() ?
TS_YES
:
TS_MAYBE
;
53
else
54
return
TS_NO
;
55
}
57
template
<
class
View>
58
forceinline
TakesStatus
59
takes
(
const
View&
x
,
const
IntSet
& s) {
60
if
((x.max() < s.
min
()) || (x.min() > s.
max
()))
61
return
TS_NO
;
62
ViewRanges<View>
ix(x);
63
IntSetRanges
is(s);
64
switch
(
Iter::Ranges::compare
(ix,is)) {
65
case
Iter::Ranges::CS_SUBSET
:
return
TS_YES
;
66
case
Iter::Ranges::CS_DISJOINT
:
return
TS_NO
;
67
case
Iter::Ranges::CS_NONE
:
return
TS_MAYBE
;
68
default
:
GECODE_NEVER
;
69
}
70
return
TS_MAYBE
;
71
}
72
74
template
<
class
View>
75
forceinline
bool
76
includes
(
const
View&
x
,
int
s) {
77
return
x.assigned() && x.in(s);
78
}
80
template
<
class
View>
81
forceinline
bool
82
includes
(
const
View&
x
,
const
IntSet
& s) {
83
if
((x.max() < s.
min
()) || (x.min() > s.
max
()))
84
return
false
;
85
ViewRanges<View>
ix(x);
86
IntSetRanges
is(s);
87
return
Iter::Ranges::subset
(ix,is);
88
}
89
91
template
<
class
View>
92
forceinline
bool
93
excludes
(
const
View&
x
,
int
s) {
94
return
!x.in(s);
95
}
97
template
<
class
View>
98
forceinline
bool
99
excludes
(
const
View&
x
,
const
IntSet
& s) {
100
if
((x.max() < s.
min
()) || (x.min() > s.
max
()))
101
return
true
;
102
ViewRanges<View>
ix(x);
103
IntSetRanges
is(s);
104
return
Iter::Ranges::disjoint
(ix,is);
105
}
106
108
template
<
class
View>
109
forceinline
bool
110
undecided
(
const
View&
x
,
int
s) {
111
return
!x.assigned() && x.in(s);
112
}
114
template
<
class
View>
115
forceinline
bool
116
undecided
(
const
View&
x
,
const
IntSet
& s) {
117
if
((x.max() < s.
min
()) || (x.min() > s.
max
()))
118
return
false
;
119
ViewRanges<View>
ix(x);
120
IntSetRanges
is(s);
121
return
Iter::Ranges::compare
(ix,is) ==
Iter::Ranges::CS_NONE
;
122
}
123
125
template
<
class
View>
126
forceinline
ModEvent
127
include
(
Space
& home, View&
x
,
int
s) {
128
return
x.eq(home,s);
129
}
131
template
<
class
View>
132
forceinline
ModEvent
133
include
(
Space
& home, View&
x
,
const
IntSet
& s) {
134
IntSetRanges
is(s);
135
return
x.inter_r(home,is,
false
);
136
}
137
139
template
<
class
View>
140
forceinline
ModEvent
141
exclude
(
Space
& home, View&
x
,
int
s) {
142
return
x.nq(home,s);
143
}
145
template
<
class
View>
146
forceinline
ModEvent
147
exclude
(
Space
& home, View&
x
,
const
IntSet
& s) {
148
IntSetRanges
is(s);
149
return
x.minus_r(home,is,
false
);
150
}
151
152
}}}
153
154
// STATISTICS: int-prop