Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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 * 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
34namespace Gecode { namespace Int { namespace ViewValGraph {
35
36 /*
37 * Nodes
38 *
39 */
40
41 template<class View>
43 Node<View>::Node(void) : min(0) {
44 // Must be initialized such that the node is considered unvisited initially
45 }
46 template<class View>
49 return static_cast<Edge<View>*>(BiLink::next());
50 }
51 template<class View>
54 return static_cast<Edge<View>*>(static_cast<BiLink*>(const_cast<Node<View>*>(this)));
55 }
56 template<class View>
57 forceinline void
58 Node<View>::operator delete(void*, size_t) {}
59 template<class View>
60 forceinline void
61 Node<View>::operator delete(void*,Space&) {}
62 template<class View>
63 forceinline void*
64 Node<View>::operator new(size_t s, Space& home) {
65 return home.ralloc(s);
66 }
67
68 /*
69 * Value nodes
70 *
71 */
72
73
74 template<class View>
77 : _val(v), _matching(NULL) {}
78 template<class View>
81 : _val(v), _matching(NULL), _next_val(n) {}
82 template<class View>
83 forceinline int
84 ValNode<View>::val(void) const {
85 return _val;
86 }
87 template<class View>
88 forceinline void
90 _matching = m;
91 }
92 template<class View>
95 return _matching;
96 }
97 template<class View>
100 return &_next_val;
101 }
102 template<class View>
105 return _next_val;
106 }
107 template<class View>
108 forceinline void
110 _next_val = n;
111 }
112
113
114
115 /*
116 * View nodes
117 *
118 */
119
120 template<class View>
123 : _view(View(NULL)) {}
124 template<class View>
127 : _size(x.size()), _view(x) {}
128 template<class View>
131 return _val_edges;
133 template<class View>
136 return &_val_edges;
137 }
138 template<class View>
139 forceinline bool
141 return _view.varimp() == NULL;
142 }
143 template<class View>
144 forceinline View
146 return _view;
147 }
148 template<class View>
149 forceinline bool
151 return _size != _view.size();
153 template<class View>
156 _size = _view.size();
157 }
158 template<class View>
159 forceinline bool
163
164}}}
165
166// STATISTICS: int-prop
167
int n
Number of negative literals for node type.
Edges in view-value graph.
Base-class for nodes (both view and value nodes)
Edge< View > * edge_fst(void) const
Return first edge (organized by bi-links)
Definition node.hpp:48
Node(void)
Initialize.
Definition node.hpp:43
Edge< View > * edge_lst(void) const
Return last edge (organized by bi-links)
Definition node.hpp:53
Value nodes in view-value graph.
ValNode(int v)
Initialize with value v.
Definition node.hpp:76
Edge< View > * matching(void) const
Return matching edge (NULL if unmatched)
Definition node.hpp:94
ValNode< View > * next_val(void) const
Return next value node.
Definition node.hpp:104
int val(void) const
Return value of node.
Definition node.hpp:84
ValNode< View > ** next_val_ref(void)
Return pointer to next value node fields.
Definition node.hpp:99
bool matched(void) const
Whether the node is matched.
Definition node.hpp:160
View view(void) const
Return view.
Definition node.hpp:145
void update(void)
Update size of view after change.
Definition node.hpp:155
Edge< View > * val_edges(void) const
Return first edge of all value edges.
Definition node.hpp:130
Edge< View > ** val_edges_ref(void)
Return pointer to first edge fields of all value edges.
Definition node.hpp:135
bool fake(void) const
Test whether node has a fake view.
Definition node.hpp:140
bool changed(void) const
Return whether view has changed its size.
Definition node.hpp:150
ViewNode(void)
Initialize node for a non-view.
Definition node.hpp:122
Computation spaces.
Definition core.hpp:1742
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
Definition set.hh:767
#define forceinline
Definition config.hpp:187