marci@9: #ifndef MARCI_PROPERTY_VECTOR_HH marci@9: #define MARCI_PROPERTY_VECTOR_HH marci@9: marci@9: #include marci@9: alpar@107: namespace hugo { marci@9: marci@9: template marci@9: int number_of(iterator _it) { marci@9: int i=0; marci@19: for( ; _it.valid(); ++_it) { ++i; } marci@9: return i; marci@9: } marci@9: marci@9: template marci@9: class node_property_vector { alpar@107: typedef typename graph_type::node_iterator node_iterator; alpar@107: typedef typename graph_type::each_node_iterator each_node_iterator; marci@9: graph_type& G; marci@9: std::vector container; marci@9: public: marci@9: node_property_vector(graph_type& _G) : G(_G) { marci@9: int i=0; marci@19: for(each_node_iterator it=G.first_node(); it.valid(); ++it) ++i; marci@9: container.resize(i); marci@9: } marci@9: node_property_vector(graph_type& _G, T a) : G(_G) { marci@19: for(each_node_iterator it=G.first_node(); it.valid(); ++it) { container.push_back(a); } marci@9: } marci@9: void put(node_iterator nit, const T& a) { container[G.id(nit)]=a; } marci@9: T get(node_iterator nit) { return container[G.id(nit)]; } marci@9: }; marci@9: marci@9: template marci@9: class edge_property_vector { marci@19: typedef typename graph_type::edge_iterator edge_iterator; marci@19: typedef typename graph_type::each_edge_iterator each_edge_iterator; marci@9: graph_type& G; marci@9: std::vector container; marci@9: public: marci@9: edge_property_vector(graph_type& _G) : G(_G) { marci@9: int i=0; marci@19: for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) ++i; marci@9: container.resize(i); marci@9: } marci@9: edge_property_vector(graph_type& _G, T a) : G(_G) { marci@19: for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) { marci@9: container.push_back(a); marci@9: } marci@9: } marci@9: void put(edge_iterator eit, const T& a) { container[G.id(eit)]=a; } marci@9: T get(edge_iterator eit) { return container[G.id(eit)]; } marci@9: }; marci@9: alpar@107: } // namespace hugo marci@9: marci@9: #endif //MARCI_PROPERTY_VECTOR_HH