diff -r 8572feccddcf -r 24c2c2989e0f src/work/list_graph.hh --- a/src/work/list_graph.hh Fri Feb 06 15:55:06 2004 +0000 +++ b/src/work/list_graph.hh Mon Feb 09 13:11:10 2004 +0000 @@ -26,36 +26,44 @@ class OutEdgeIt; class InEdgeIt; class SymEdgeIt; - template class NodeMap; - template class EdgeMap; + template class NodeMap; + template class EdgeMap; private: - template friend class NodeMap; - template friend class EdgeMap; + template friend class NodeMap; + template friend class EdgeMap; - template + template class NodeMap { const ListGraph& G; - std::vector container; + std::vector container; public: - NodeMap(const ListGraph& _G) : G(_G), container(_G.node_id) { } - NodeMap(const ListGraph& _G, ValueType a) : - G(_G), container(_G.node_id, a) { } - void set(NodeIt nit, ValueType a) { container[G.id(nit)]=a; } - ValueType get(NodeIt nit) const { return container[G.id(nit)]; } + typedef T ValueType; + typedef NodeIt KeyType; + NodeMap(const ListGraph& _G) : G(_G), container(G.node_id) { } + NodeMap(const ListGraph& _G, T a) : + G(_G), container(G.node_id, a) { } + void set(NodeIt nit, T a) { container[G.id(nit)]=a; } + T get(NodeIt nit) const { return container[G.id(nit)]; } + void resize() { container.resize(G.node_id); } + void resize(T a) { container.resize(G.node_id, a); } }; - template + template class EdgeMap { const ListGraph& G; - std::vector container; + std::vector container; public: - EdgeMap(const ListGraph& _G) : G(_G), container(_G.edge_id) { } - EdgeMap(const ListGraph& _G, ValueType a) : - G(_G), container(_G.edge_id, a) { } - void set(EdgeIt eit, ValueType a) { container[G.id(eit)]=a; } - ValueType get(EdgeIt eit) const { return container[G.id(eit)]; } + typedef T ValueType; + typedef EdgeIt KeyType; + EdgeMap(const ListGraph& _G) : G(_G), container(G.edge_id) { } + EdgeMap(const ListGraph& _G, T a) : + G(_G), container(G.edge_id, a) { } + void set(EdgeIt eit, T a) { container[G.id(eit)]=a; } + T get(EdgeIt eit) const { return container[G.id(eit)]; } + void resize() { container.resize(G.edge_id); } + void resize(T a) { container.resize(G.edge_id, a); } }; int node_id; @@ -301,6 +309,10 @@ void erase(EdgeIt e) { _delete_edge(e.edge); } + void clear() { + while (first().valid()) erase(first()); + } + void setTail(EdgeIt e, NodeIt tail) { _set_tail(e.edge, tail.node); }