node.icc
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: 2007-08-09 15:30:21 +0200 (Thu, 09 Aug 2007) $ by $Author: tack $ 00011 * $Revision: 4790 $ 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 Distinct { 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->alloc(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(View x) 00127 : _view(x) {} 00128 template <class View> 00129 forceinline Edge<View>* 00130 ViewNode<View>::val_edges(void) const { 00131 return _val_edges; 00132 } 00133 template <class View> 00134 forceinline Edge<View>** 00135 ViewNode<View>::val_edges_ref(void) { 00136 return &_val_edges; 00137 } 00138 template <class View> 00139 forceinline View 00140 ViewNode<View>::view(void) const { 00141 return _view; 00142 } 00143 00144 }}} 00145 00146 // STATISTICS: int-prop 00147