Generated on Thu Mar 22 10:39:32 2012 for Gecode by doxygen 1.6.3

node.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2003
00008  *
00009  *  Last modified:
00010  *     $Date: 2011-09-08 14:34:40 +0200 (Thu, 08 Sep 2011) $ by $Author: schulte $
00011  *     $Revision: 12395 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode { namespace Int { namespace ViewValGraph {
00039 
00040   /*
00041    * Nodes
00042    *
00043    */
00044 
00045   template<class View>
00046   forceinline
00047   Node<View>::Node(void) : min(0) {
00048     // Must be initialized such that the node is considered unvisited initially
00049   }
00050   template<class View>
00051   forceinline Edge<View>*
00052   Node<View>::edge_fst(void) const {
00053     return static_cast<Edge<View>*>(BiLink::next());
00054   }
00055   template<class View>
00056   forceinline Edge<View>*
00057   Node<View>::edge_lst(void) const {
00058     return static_cast<Edge<View>*>(static_cast<BiLink*>(const_cast<Node<View>*>(this)));
00059   }
00060   template<class View>
00061   forceinline void
00062   Node<View>::operator delete(void*, size_t) {}
00063   template<class View>
00064   forceinline void
00065   Node<View>::operator delete(void*,Space&) {}
00066   template<class View>
00067   forceinline void*
00068   Node<View>::operator new(size_t s, Space& home) {
00069     return home.ralloc(s);
00070   }
00071 
00072   /*
00073    * Value nodes
00074    *
00075    */
00076 
00077 
00078   template<class View>
00079   forceinline
00080   ValNode<View>::ValNode(int v)
00081     : _val(v), _matching(NULL) {}
00082   template<class View>
00083   forceinline
00084   ValNode<View>::ValNode(int v, ValNode<View>* n)
00085     : _val(v), _matching(NULL), _next_val(n) {}
00086   template<class View>
00087   forceinline int
00088   ValNode<View>::val(void) const {
00089     return _val;
00090   }
00091   template<class View>
00092   forceinline void
00093   ValNode<View>::matching(Edge<View>* m) {
00094     _matching = m;
00095   }
00096   template<class View>
00097   forceinline Edge<View>*
00098   ValNode<View>::matching(void) const {
00099     return _matching;
00100   }
00101   template<class View>
00102   forceinline ValNode<View>**
00103   ValNode<View>::next_val_ref(void) {
00104     return &_next_val;
00105   }
00106   template<class View>
00107   forceinline ValNode<View>*
00108   ValNode<View>::next_val(void) const {
00109     return _next_val;
00110   }
00111   template<class View>
00112   forceinline void
00113   ValNode<View>::next_val(ValNode<View>* n) {
00114     _next_val = n;
00115   }
00116 
00117 
00118 
00119   /*
00120    * View nodes
00121    *
00122    */
00123 
00124   template<class View>
00125   forceinline
00126   ViewNode<View>::ViewNode(void)
00127     : _view(View(NULL)) {}
00128   template<class View>
00129   forceinline
00130   ViewNode<View>::ViewNode(View x)
00131     : _size(x.size()), _view(x) {}
00132   template<class View>
00133   forceinline Edge<View>*
00134   ViewNode<View>::val_edges(void) const {
00135     return _val_edges;
00136   }
00137   template<class View>
00138   forceinline Edge<View>**
00139   ViewNode<View>::val_edges_ref(void) {
00140     return &_val_edges;
00141   }
00142   template<class View>
00143   forceinline bool
00144   ViewNode<View>::fake(void) const {
00145     return _view.varimp() == NULL;
00146   }
00147   template<class View>
00148   forceinline View
00149   ViewNode<View>::view(void) const {
00150     return _view;
00151   }
00152   template<class View>
00153   forceinline bool
00154   ViewNode<View>::changed(void) const {
00155     return _size != _view.size();
00156   }
00157   template<class View>
00158   forceinline void
00159   ViewNode<View>::update(void) {
00160     _size = _view.size();
00161   }
00162   template<class View>
00163   forceinline bool
00164   ViewNode<View>::matched(void) const {
00165     return Node<View>::edge_fst() != Node<View>::edge_lst();
00166   }
00167 
00168 }}}
00169 
00170 // STATISTICS: int-prop
00171