deba@262: #ifndef EDGE_MAP_REGISTER_H deba@262: #define EDGE_MAP_REGISTER_H deba@262: deba@262: #include deba@262: deba@262: template deba@262: class EdgeMapRegister { deba@262: public: deba@262: typedef G Graph; deba@262: typedef E Edge deba@262: deba@262: typedef EdgeMapBase EdgeMapBase; deba@262: deba@262: protected: deba@262: typedef std::vector Container; deba@262: deba@262: Container container; deba@262: deba@262: void add(EdgeMapBase& map_base) { deba@262: if (map_base.graph) { deba@262: map_base.graph->edge_maps.erase(map_base); deba@262: } deba@262: container.push_back(&map_base); deba@262: map_base.graph_index = container.size()-1; deba@262: } deba@262: deba@262: void erase(EdgeMapBase& map_base) { deba@262: if (map_base.graph != this) return; deba@262: container.back()->graph_index = map_base.graph_index; deba@262: container[map_base.graph_index] = container.back(); deba@262: container.pop_back(); deba@262: map_base.graph = 0; deba@262: } deba@262: deba@262: void addEdge(Edge& edge) { deba@262: typename Container::iterator it; deba@262: for (it = container.begin(); it != container.end(); ++it) { deba@262: (*it)->add(edge); deba@262: } deba@262: } deba@262: deba@262: void eraseEdge(Edge& edge) { deba@262: typename Container::iterator it; deba@262: for (it = container.begin(); it != container.end(); ++it) { deba@262: (*it)->erase(edge); deba@262: } deba@262: } deba@262: deba@262: friend class EdgeMapBase; deba@262: }; deba@262: deba@262: #endif