node.hpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2003
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode { namespace Int { namespace ViewValGraph {
/*
* Nodes
*
*/
template<class View>
forceinline
Node<View>::Node(void) : min(0) {
// Must be initialized such that the node is considered unvisited initially
}
template<class View>
forceinline Edge<View>*
Node<View>::edge_fst(void) const {
return static_cast<Edge<View>*>(BiLink::next());
}
template<class View>
forceinline Edge<View>*
Node<View>::edge_lst(void) const {
return static_cast<Edge<View>*>(static_cast<BiLink*>(const_cast<Node<View>*>(this)));
}
template<class View>
forceinline void
Node<View>::operator delete(void*, size_t) {}
template<class View>
forceinline void
Node<View>::operator delete(void*,Space&) {}
template<class View>
forceinline void*
Node<View>::operator new(size_t s, Space& home) {
return home.ralloc(s);
}
/*
* Value nodes
*
*/
template<class View>
forceinline
ValNode<View>::ValNode(int v)
: _val(v), _matching(NULL) {}
template<class View>
forceinline
ValNode<View>::ValNode(int v, ValNode<View>* n)
: _val(v), _matching(NULL), _next_val(n) {}
template<class View>
forceinline int
ValNode<View>::val(void) const {
return _val;
}
template<class View>
forceinline void
ValNode<View>::matching(Edge<View>* m) {
_matching = m;
}
template<class View>
forceinline Edge<View>*
ValNode<View>::matching(void) const {
return _matching;
}
template<class View>
forceinline ValNode<View>**
ValNode<View>::next_val_ref(void) {
return &_next_val;
}
template<class View>
forceinline ValNode<View>*
ValNode<View>::next_val(void) const {
return _next_val;
}
template<class View>
forceinline void
ValNode<View>::next_val(ValNode<View>* n) {
_next_val = n;
}
/*
* View nodes
*
*/
template<class View>
forceinline
ViewNode<View>::ViewNode(void)
: _view(View(NULL)) {}
template<class View>
forceinline
ViewNode<View>::ViewNode(View x)
: _size(x.size()), _view(x) {}
template<class View>
forceinline Edge<View>*
ViewNode<View>::val_edges(void) const {
return _val_edges;
}
template<class View>
forceinline Edge<View>**
ViewNode<View>::val_edges_ref(void) {
return &_val_edges;
}
template<class View>
forceinline bool
ViewNode<View>::fake(void) const {
return _view.varimp() == NULL;
}
template<class View>
forceinline View
ViewNode<View>::view(void) const {
return _view;
}
template<class View>
forceinline bool
ViewNode<View>::changed(void) const {
return _size != _view.size();
}
template<class View>
forceinline void
ViewNode<View>::update(void) {
_size = _view.size();
}
template<class View>
forceinline bool
ViewNode<View>::matched(void) const {
return Node<View>::edge_fst() != Node<View>::edge_lst();
}
}}}
// STATISTICS: int-prop
Gecode::Int::ViewValGraph::BiLink::BiLink
BiLink(void)
Initialize as empty (self referenced).
Definition bi-link.hpp:37
Gecode::Int::ViewValGraph::BiLink::next
BiLink * next(void) const
Return next element.
Definition bi-link.hpp:46
Gecode::Int::ViewValGraph::Edge
Edges in view-value graph.
Definition view-val-graph.hh:208
Gecode::Int::ViewValGraph::Node::edge_fst
Edge< View > * edge_fst(void) const
Return first edge (organized by bi-links).
Definition node.hpp:48
Gecode::Int::ViewValGraph::Node::min
unsigned int min
Definition view-val-graph.hh:121
Gecode::Int::ViewValGraph::Node::Node
Node(void)
Initialize.
Definition node.hpp:43
Gecode::Int::ViewValGraph::Node::edge_lst
Edge< View > * edge_lst(void) const
Return last edge (organized by bi-links).
Definition node.hpp:53
Gecode::Int::ViewValGraph::ValNode
Value nodes in view-value graph.
Definition view-val-graph.hh:142
Gecode::Int::ViewValGraph::ValNode::_val
const int _val
The value of the node.
Definition view-val-graph.hh:145
Gecode::Int::ViewValGraph::ValNode::ValNode
ValNode(int v)
Initialize with value v.
Definition node.hpp:76
Gecode::Int::ViewValGraph::ValNode::matching
Edge< View > * matching(void) const
Return matching edge (NULL if unmatched).
Definition node.hpp:94
Gecode::Int::ViewValGraph::ValNode::_next_val
ValNode< View > * _next_val
The next value node.
Definition view-val-graph.hh:149
Gecode::Int::ViewValGraph::ValNode::_matching
Edge< View > * _matching
The matching edge.
Definition view-val-graph.hh:147
Gecode::Int::ViewValGraph::ValNode::next_val
ValNode< View > * next_val(void) const
Return next value node.
Definition node.hpp:104
Gecode::Int::ViewValGraph::ValNode::val
int val(void) const
Return value of node.
Definition node.hpp:84
Gecode::Int::ViewValGraph::ValNode::next_val_ref
ValNode< View > ** next_val_ref(void)
Return pointer to next value node fields.
Definition node.hpp:99
Gecode::Int::ViewValGraph::ViewNode::_view
View _view
The node's view.
Definition view-val-graph.hh:179
Gecode::Int::ViewValGraph::ViewNode::matched
bool matched(void) const
Whether the node is matched.
Definition node.hpp:160
Gecode::Int::ViewValGraph::ViewNode::view
View view(void) const
Return view.
Definition node.hpp:145
Gecode::Int::ViewValGraph::ViewNode::update
void update(void)
Update size of view after change.
Definition node.hpp:155
Gecode::Int::ViewValGraph::ViewNode::_size
unsigned int _size
The size of the view after last change.
Definition view-val-graph.hh:177
Gecode::Int::ViewValGraph::ViewNode::val_edges
Edge< View > * val_edges(void) const
Return first edge of all value edges.
Definition node.hpp:130
Gecode::Int::ViewValGraph::ViewNode::val_edges_ref
Edge< View > ** val_edges_ref(void)
Return pointer to first edge fields of all value edges.
Definition node.hpp:135
Gecode::Int::ViewValGraph::ViewNode::fake
bool fake(void) const
Test whether node has a fake view.
Definition node.hpp:140
Gecode::Int::ViewValGraph::ViewNode::changed
bool changed(void) const
Return whether view has changed its size.
Definition node.hpp:150
Gecode::Int::ViewValGraph::ViewNode::_val_edges
Edge< View > * _val_edges
The first value edge.
Definition view-val-graph.hh:181
Gecode::Int::ViewValGraph::ViewNode::ViewNode
ViewNode(void)
Initialize node for a non-view.
Definition node.hpp:122
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::View
Gecode::Int::ViewValGraph
Support classes for propagators using a view-value graph.
Gecode::Int
Finite domain integers.
Gecode
Gecode toplevel namespace
forceinline
#define forceinline
Definition config.hpp:187