1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/deba/edge_map_registry.h Fri Apr 16 12:15:17 2004 +0000
1.3 @@ -0,0 +1,53 @@
1.4 +#ifndef EDGE_MAP_REGISTRY_H
1.5 +#define EDGE_MAP_REGISTRY_H
1.6 +
1.7 +#include <vector>
1.8 +
1.9 +template <typename G, typename E>
1.10 +class EdgeMapRegistry {
1.11 +public:
1.12 + typedef G Graph;
1.13 + typedef E Edge
1.14 +
1.15 + typedef EdgeMapBase<Graph, Edge> EdgeMapBase;
1.16 +
1.17 +protected:
1.18 + typedef std::vector<EdgeMapBase*> Container;
1.19 +
1.20 + Container container;
1.21 +
1.22 + void add(EdgeMapBase& map_base) {
1.23 + if (map_base.graph) {
1.24 + map_base.graph->edge_maps.erase(map_base);
1.25 + }
1.26 + container.push_back(&map_base);
1.27 + map_base.graph = this;
1.28 + map_base.graph_index = container.size()-1;
1.29 + }
1.30 +
1.31 + void erase(EdgeMapBase& map_base) {
1.32 + if (map_base.graph != this) return;
1.33 + container.back()->graph_index = map_base.graph_index;
1.34 + container[map_base.graph_index] = container.back();
1.35 + container.pop_back();
1.36 + map_base.graph = 0;
1.37 + }
1.38 +
1.39 + void addEdge(Edge& edge) {
1.40 + typename Container::iterator it;
1.41 + for (it = container.begin(); it != container.end(); ++it) {
1.42 + (*it)->add(edge);
1.43 + }
1.44 + }
1.45 +
1.46 + void eraseEdge(Edge& edge) {
1.47 + typename Container::iterator it;
1.48 + for (it = container.begin(); it != container.end(); ++it) {
1.49 + (*it)->erase(edge);
1.50 + }
1.51 + }
1.52 +
1.53 + friend class EdgeMapBase;
1.54 +};
1.55 +
1.56 +#endif