diff -r be43902fadb7 -r 19f3943521ab src/work/marci/oldies/marci_property_vector.hh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/oldies/marci_property_vector.hh Sat Apr 03 14:41:31 2004 +0000 @@ -0,0 +1,57 @@ +#ifndef MARCI_PROPERTY_VECTOR_HH +#define MARCI_PROPERTY_VECTOR_HH + +#include + +namespace hugo { + + template + int number_of(iterator _it) { + int i=0; + for( ; _it.valid(); ++_it) { ++i; } + return i; + } + + template + class node_property_vector { + typedef typename graph_type::node_iterator node_iterator; + typedef typename graph_type::each_node_iterator each_node_iterator; + graph_type& G; + std::vector container; + public: + node_property_vector(graph_type& _G) : G(_G) { + int i=0; + for(each_node_iterator it=G.first_node(); it.valid(); ++it) ++i; + container.resize(i); + } + node_property_vector(graph_type& _G, T a) : G(_G) { + for(each_node_iterator it=G.first_node(); it.valid(); ++it) { container.push_back(a); } + } + void put(node_iterator nit, const T& a) { container[G.id(nit)]=a; } + T get(node_iterator nit) { return container[G.id(nit)]; } + }; + + template + class edge_property_vector { + typedef typename graph_type::edge_iterator edge_iterator; + typedef typename graph_type::each_edge_iterator each_edge_iterator; + graph_type& G; + std::vector container; + public: + edge_property_vector(graph_type& _G) : G(_G) { + int i=0; + for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) ++i; + container.resize(i); + } + edge_property_vector(graph_type& _G, T a) : G(_G) { + for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) { + container.push_back(a); + } + } + void put(edge_iterator eit, const T& a) { container[G.id(eit)]=a; } + T get(edge_iterator eit) { return container[G.id(eit)]; } + }; + +} // namespace hugo + +#endif //MARCI_PROPERTY_VECTOR_HH