Changeset 69:24c2c2989e0f in lemon0.x for src/work/list_graph.hh
 Timestamp:
 02/09/04 14:11:10 (19 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@85
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/list_graph.hh
r67 r69 27 27 class InEdgeIt; 28 28 class SymEdgeIt; 29 template <typename ValueType> class NodeMap;30 template <typename ValueType> class EdgeMap;29 template <typename T> class NodeMap; 30 template <typename T> class EdgeMap; 31 31 32 32 private: 33 33 34 template <typename ValueType> friend class NodeMap;35 template <typename ValueType> friend class EdgeMap;36 37 template <typename ValueType>34 template <typename T> friend class NodeMap; 35 template <typename T> friend class EdgeMap; 36 37 template <typename T> 38 38 class NodeMap { 39 39 const ListGraph& G; 40 std::vector<ValueType> container; 41 public: 42 NodeMap(const ListGraph& _G) : G(_G), container(_G.node_id) { } 43 NodeMap(const ListGraph& _G, ValueType a) : 44 G(_G), container(_G.node_id, a) { } 45 void set(NodeIt nit, ValueType a) { container[G.id(nit)]=a; } 46 ValueType get(NodeIt nit) const { return container[G.id(nit)]; } 47 }; 48 49 template <typename ValueType> 40 std::vector<T> container; 41 public: 42 typedef T ValueType; 43 typedef NodeIt KeyType; 44 NodeMap(const ListGraph& _G) : G(_G), container(G.node_id) { } 45 NodeMap(const ListGraph& _G, T a) : 46 G(_G), container(G.node_id, a) { } 47 void set(NodeIt nit, T a) { container[G.id(nit)]=a; } 48 T get(NodeIt nit) const { return container[G.id(nit)]; } 49 void resize() { container.resize(G.node_id); } 50 void resize(T a) { container.resize(G.node_id, a); } 51 }; 52 53 template <typename T> 50 54 class EdgeMap { 51 55 const ListGraph& G; 52 std::vector<ValueType> container; 53 public: 54 EdgeMap(const ListGraph& _G) : G(_G), container(_G.edge_id) { } 55 EdgeMap(const ListGraph& _G, ValueType a) : 56 G(_G), container(_G.edge_id, a) { } 57 void set(EdgeIt eit, ValueType a) { container[G.id(eit)]=a; } 58 ValueType get(EdgeIt eit) const { return container[G.id(eit)]; } 56 std::vector<T> container; 57 public: 58 typedef T ValueType; 59 typedef EdgeIt KeyType; 60 EdgeMap(const ListGraph& _G) : G(_G), container(G.edge_id) { } 61 EdgeMap(const ListGraph& _G, T a) : 62 G(_G), container(G.edge_id, a) { } 63 void set(EdgeIt eit, T a) { container[G.id(eit)]=a; } 64 T get(EdgeIt eit) const { return container[G.id(eit)]; } 65 void resize() { container.resize(G.edge_id); } 66 void resize(T a) { container.resize(G.edge_id, a); } 59 67 }; 60 68 … … 302 310 void erase(EdgeIt e) { _delete_edge(e.edge); } 303 311 312 void clear() { 313 while (first<EachNodeIt>().valid()) erase(first<EachNodeIt>()); 314 } 315 304 316 void setTail(EdgeIt e, NodeIt tail) { 305 317 _set_tail(e.edge, tail.node);
Note: See TracChangeset
for help on using the changeset viewer.