main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:02 for Gecode by
doxygen
1.8.4
gecode
int
view-val-graph
node.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, 2003
8
*
9
* Last modified:
10
* $Date: 2011-09-08 14:34:40 +0200 (Thu, 08 Sep 2011) $ by $Author: schulte $
11
* $Revision: 12395 $
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
ViewValGraph {
39
40
/*
41
* Nodes
42
*
43
*/
44
45
template
<
class
View>
46
forceinline
47
Node<View>::Node
(
void
) :
min
(0) {
48
// Must be initialized such that the node is considered unvisited initially
49
}
50
template
<
class
View>
51
forceinline
Edge<View>
*
52
Node<View>::edge_fst
(
void
)
const
{
53
return
static_cast<
Edge<View>
*
>
(
BiLink::next
());
54
}
55
template
<
class
View>
56
forceinline
Edge<View>
*
57
Node<View>::edge_lst
(
void
)
const
{
58
return
static_cast<
Edge<View>
*
>
(
static_cast<
BiLink
*
>
(
const_cast<
Node<View>
*
>
(
this
)));
59
}
60
template
<
class
View>
61
forceinline
void
62
Node<View>::operator
delete
(
void
*, size_t) {}
63
template
<
class
View>
64
forceinline
void
65
Node<View>::operator
delete
(
void
*,
Space
&) {}
66
template
<
class
View>
67
forceinline
void
*
68
Node<View>::operator
new
(
size_t
s,
Space
& home) {
69
return
home.ralloc(s);
70
}
71
72
/*
73
* Value nodes
74
*
75
*/
76
77
78
template
<
class
View>
79
forceinline
80
ValNode<View>::ValNode
(
int
v
)
81
: _val(v), _matching(NULL) {}
82
template
<
class
View>
83
forceinline
84
ValNode<View>::ValNode
(
int
v
,
ValNode<View>
*
n
)
85
: _val(v), _matching(NULL), _next_val(n) {}
86
template
<
class
View>
87
forceinline
int
88
ValNode<View>::val
(
void
)
const
{
89
return
_val;
90
}
91
template
<
class
View>
92
forceinline
void
93
ValNode<View>::matching
(
Edge<View>
* m) {
94
_matching = m;
95
}
96
template
<
class
View>
97
forceinline
Edge<View>
*
98
ValNode<View>::matching
(
void
)
const
{
99
return
_matching;
100
}
101
template
<
class
View>
102
forceinline
ValNode<View>
**
103
ValNode<View>::next_val_ref
(
void
) {
104
return
&_next_val;
105
}
106
template
<
class
View>
107
forceinline
ValNode<View>
*
108
ValNode<View>::next_val
(
void
)
const
{
109
return
_next_val;
110
}
111
template
<
class
View>
112
forceinline
void
113
ValNode<View>::next_val
(
ValNode<View>
*
n
) {
114
_next_val =
n
;
115
}
116
117
118
119
/*
120
* View nodes
121
*
122
*/
123
124
template
<
class
View>
125
forceinline
126
ViewNode<View>::ViewNode
(
void
)
127
: _view(View(NULL)) {}
128
template
<
class
View>
129
forceinline
130
ViewNode<View>::ViewNode
(View
x
)
131
: _size(x.
size
()), _view(x) {}
132
template
<
class
View>
133
forceinline
Edge<View>
*
134
ViewNode<View>::val_edges
(
void
)
const
{
135
return
_val_edges;
136
}
137
template
<
class
View>
138
forceinline
Edge<View>
**
139
ViewNode<View>::val_edges_ref
(
void
) {
140
return
&_val_edges;
141
}
142
template
<
class
View>
143
forceinline
bool
144
ViewNode<View>::fake
(
void
)
const
{
145
return
_view.varimp() == NULL;
146
}
147
template
<
class
View>
148
forceinline
View
149
ViewNode<View>::view
(
void
)
const
{
150
return
_view;
151
}
152
template
<
class
View>
153
forceinline
bool
154
ViewNode<View>::changed
(
void
)
const
{
155
return
_size != _view.size();
156
}
157
template
<
class
View>
158
forceinline
void
159
ViewNode<View>::update
(
void
) {
160
_size = _view.size();
161
}
162
template
<
class
View>
163
forceinline
bool
164
ViewNode<View>::matched
(
void
)
const
{
165
return
Node<View>::edge_fst
() !=
Node<View>::edge_lst
();
166
}
167
168
}}}
169
170
// STATISTICS: int-prop
171