main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Feb 8 2021 00:00:00 for Gecode by
doxygen
1.8.20
gecode
int
task
array.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
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
namespace
Gecode
{
namespace
Int {
35
36
/*
37
* Task array
38
*/
39
40
template
<
class
Task>
41
forceinline
42
TaskArray<Task>::TaskArray
(
void
)
43
:
n
(0),
t
(NULL) {}
44
template
<
class
Task>
45
forceinline
46
TaskArray<Task>::TaskArray
(
Space
& home,
int
n0)
47
:
n
(n0),
t
(home.alloc<Task>(
n
)) {
48
assert(n > 0);
49
}
50
template
<
class
Task>
51
forceinline
52
TaskArray<Task>::TaskArray
(
const
TaskArray<Task>
&
a
)
53
:
n
(
a
.
n
),
t
(
a
.
t
) {}
54
template
<
class
Task>
55
forceinline
const
TaskArray<Task>
&
56
TaskArray<Task>::operator =
(
const
TaskArray<Task>
&
a
) {
57
n
=
a
.n;
t
=
a
.t;
58
return
*
this
;
59
}
60
61
template
<
class
Task>
62
forceinline
int
63
TaskArray<Task>::size
(
void
)
const
{
64
return
n
;
65
}
66
template
<
class
Task>
67
forceinline
void
68
TaskArray<Task>::size
(
int
n0) {
69
n
= n0;
70
}
71
72
template
<
class
Task>
73
forceinline
Task&
74
TaskArray<Task>::operator []
(
int
i
) {
75
assert((
i
>= 0) && (
i
<
n
));
76
return
t
[
i
];
77
}
78
template
<
class
Task>
79
forceinline
const
Task&
80
TaskArray<Task>::operator []
(
int
i
)
const
{
81
assert((
i
>= 0) && (
i
<
n
));
82
return
t
[
i
];
83
}
84
85
template
<
class
Task>
86
forceinline
void
87
TaskArray<Task>::subscribe
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
88
for
(
int
i
=0;
i
<
n
;
i
++)
89
t
[
i
].
subscribe
(home,
p
,pc);
90
}
91
92
template
<
class
Task>
93
forceinline
void
94
TaskArray<Task>::cancel
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
95
for
(
int
i
=0;
i
<
n
;
i
++)
96
t
[
i
].
cancel
(home,
p
,pc);
97
}
98
99
template
<
class
Task>
100
forceinline
void
101
TaskArray<Task>::reschedule
(
Space
& home,
Propagator
&
p
,
PropCond
pc) {
102
for
(
int
i
=0;
i
<
n
;
i
++)
103
t
[
i
].
reschedule
(home,
p
,pc);
104
}
105
106
template
<
class
Task>
107
forceinline
void
108
TaskArray<Task>::update
(
Space
& home,
TaskArray
&
a
) {
109
n
=
a
.n;
t
=home.
alloc
<Task>(
n
);
110
for
(
int
i
=0;
i
<
n
;
i
++)
111
t
[
i
].
update
(home,
a
.t[
i
]);
112
}
113
114
115
template
<
class
Char,
class
Traits,
class
Task>
116
std::basic_ostream<Char,Traits>&
117
operator <<
(std::basic_ostream<Char,Traits>& os,
118
const
TaskArray<Task>
&
t
) {
119
std::basic_ostringstream<Char,Traits> s;
120
s.copyfmt(os); s.width(0);
121
s <<
'{'
;
122
if
(
t
.size() > 0) {
123
s <<
t
[0];
124
for
(
int
i
=1;
i
<
t
.size();
i
++)
125
s <<
", "
<<
t
[
i
];
126
}
127
s <<
'}'
;
128
return
os << s.str();
129
}
130
131
132
/*
133
* Task view array
134
*/
135
template
<
class
TaskView>
136
forceinline
137
TaskViewArray<TaskView>::TaskViewArray
(
TaskArray<Task>
& t0)
138
:
t
(t0) {}
139
140
template
<
class
TaskView>
141
forceinline
int
142
TaskViewArray<TaskView>::size
(
void
)
const
{
143
return
t
.size();
144
}
145
146
template
<
class
TaskView>
147
forceinline
void
148
TaskViewArray<TaskView>::size
(
int
n
) {
149
t
.size(
n
);
150
}
151
152
template
<
class
TaskView>
153
forceinline
TaskView&
154
TaskViewArray<TaskView>::operator []
(
int
i
) {
155
return
static_cast<
TaskView&
>
(
t
[
i
]);
156
}
157
template
<
class
TaskView>
158
forceinline
const
TaskView&
159
TaskViewArray<TaskView>::operator []
(
int
i
)
const
{
160
return
static_cast<
const
TaskView&
>
(
t
[
i
]);
161
}
162
163
template
<
class
Char,
class
Traits,
class
TaskView>
164
std::basic_ostream<Char,Traits>&
165
operator <<
(std::basic_ostream<Char,Traits>& os,
166
const
TaskViewArray<TaskView>
&
t
) {
167
std::basic_ostringstream<Char,Traits> s;
168
s.copyfmt(os); s.width(0);
169
s <<
'{'
;
170
if
(
t
.size() > 0) {
171
s <<
t
[0];
172
for
(
int
i
=1;
i
<
t
.size();
i
++)
173
s <<
", "
<<
t
[
i
];
174
}
175
s <<
'}'
;
176
return
os << s.str();
177
}
178
179
180
}}
181
182
// STATISTICS: int-other
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:230
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Int::TaskArray::subscribe
void subscribe(Space &home, Propagator &p, PropCond pc=Int::PC_INT_BND)
Subscribe propagator p to all tasks.
Definition:
array.hpp:87
Gecode
Gecode toplevel namespace
Gecode::Propagator
Base-class for propagators.
Definition:
core.hpp:1064
Gecode::Int::Count::update
void update(IntSet &y, Space &home, IntSet &py)
Definition:
rel.hpp:103
Gecode::Int::Count::reschedule
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:92
Gecode::Int::TaskArray::TaskArray
TaskArray(void)
Default constructor (array of size 0)
Definition:
array.hpp:42
Gecode::Int::TaskArray::reschedule
void reschedule(Space &home, Propagator &p, PropCond pc=Int::PC_INT_BND)
Schedule propagator p.
Definition:
array.hpp:101
Gecode::Int::TaskArray::operator[]
Task & operator[](int i)
Return task at position i.
Definition:
array.hpp:74
Gecode::Space::alloc
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Definition:
core.hpp:2837
Gecode::Int::operator<<
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const IdxViewArray< View > &x)
Definition:
idx-view.hpp:167
a
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Gecode::Int::TaskArray::cancel
void cancel(Space &home, Propagator &p, PropCond pc=Int::PC_INT_BND)
Cancel subscription of propagator p for all tasks.
Definition:
array.hpp:94
Gecode::PropCond
int PropCond
Type for propagation conditions.
Definition:
core.hpp:72
Gecode::Int::TaskArray::size
int size(void) const
Return size of array (number of elements)
Definition:
array.hpp:63
Gecode::Int::TaskViewArray::operator[]
TaskView & operator[](int i)
Return task view at position i.
Definition:
array.hpp:154
Gecode::Int::Count::cancel
void cancel(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:81
Gecode::Int::TaskArray::operator=
const TaskArray< Task > & operator=(const TaskArray< Task > &a)
Initialize from task array a (share elements)
Definition:
array.hpp:56
Gecode::Int::TaskArray::update
void update(Space &, TaskArray &a)
Update array to be a clone of array a.
Definition:
array.hpp:108
Gecode::Int::TaskViewArray::size
int size(void) const
Return size of array (number of elements)
Definition:
array.hpp:142
Gecode::Int::TaskArray
Task array.
Definition:
task.hh:165
forceinline
#define forceinline
Definition:
config.hpp:192
Gecode::Int::TaskViewArray::TaskViewArray
TaskViewArray(TaskArray< Task > &t)
Initialize from task array a.
Definition:
array.hpp:137
Gecode::Int::TaskViewArray
Task view array.
Definition:
task.hh:233
Gecode::Int::Count::subscribe
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition:
rel.hpp:71
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232