Changeset 821:f4b5c2d5449d in lemon for lemon/static_graph.h
- Timestamp:
- 08/25/09 13:58:43 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/static_graph.h
r820 r821 33 33 34 34 StaticDigraphBase() 35 : node_num(-1), arc_num(0),35 : built(false), node_num(0), arc_num(0), 36 36 node_first_out(NULL), node_first_in(NULL), 37 37 arc_source(NULL), arc_target(NULL), … … 39 39 40 40 ~StaticDigraphBase() { 41 if ( node_num != -1) {41 if (built) { 42 42 delete[] node_first_out; 43 43 delete[] node_first_in; … … 129 129 typedef True BuildTag; 130 130 131 template <typename Digraph, typename NodeRefMap, typename ArcRefMap> 132 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { 133 134 if (node_num != -1) { 131 void clear() { 132 if (built) { 135 133 delete[] node_first_out; 136 134 delete[] node_first_in; … … 140 138 delete[] arc_next_in; 141 139 } 142 140 built = false; 141 node_num = 0; 142 arc_num = 0; 143 } 144 145 template <typename Digraph, typename NodeRefMap, typename ArcRefMap> 146 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { 143 147 typedef typename Digraph::Node GNode; 144 148 typedef typename Digraph::Arc GArc; 149 150 built = true; 145 151 146 152 node_num = countNodes(digraph); … … 206 212 } 207 213 208 private: 214 protected: 215 bool built; 209 216 int node_num; 210 217 int arc_num; … … 224 231 225 232 typedef ExtendedStaticDigraphBase Parent; 233 234 public: 235 236 template <typename Digraph, typename NodeRefMap, typename ArcRefMap> 237 void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) { 238 if (built) Parent::clear(); 239 Parent::build(digraph, nodeRef, arcRef); 240 } 241 226 242 227 243 protected: … … 262 278 }; 263 279 280 Node baseNode(const OutArcIt &arc) const { 281 return Parent::source(static_cast<const Arc&>(arc)); 282 } 283 284 Node runningNode(const OutArcIt &arc) const { 285 return Parent::target(static_cast<const Arc&>(arc)); 286 } 287 288 Node baseNode(const InArcIt &arc) const { 289 return Parent::target(static_cast<const Arc&>(arc)); 290 } 291 292 Node runningNode(const InArcIt &arc) const { 293 return Parent::source(static_cast<const Arc&>(arc)); 294 } 295 264 296 }; 265 297
Note: See TracChangeset
for help on using the changeset viewer.