1.1 --- a/src/work/deba/node_map_registry.h Thu Apr 22 16:07:17 2004 +0000
1.2 +++ b/src/work/deba/node_map_registry.h Thu Apr 22 16:36:57 2004 +0000
1.3 @@ -3,37 +3,48 @@
1.4
1.5 #include <vector>
1.6
1.7 +template <typename G, typename K>
1.8 +class NodeMapRegistry;
1.9 +
1.10 #include "node_map_base.h"
1.11
1.12 -template <typename G, typename E>
1.13 +template <typename G, typename K>
1.14 class NodeMapRegistry {
1.15 public:
1.16 typedef G Graph;
1.17 - typedef E Node
1.18 + typedef K Node;
1.19
1.20 - typedef NodeMapBase<Graph, Node> NodeMapBase;
1.21 + typedef NodeMapBase<Graph, Node> MapBase;
1.22 + friend class MapBase;
1.23
1.24 protected:
1.25 - typedef std::vector<NodeMapBase*> Container;
1.26 +
1.27 + Graph* graph;
1.28 +
1.29 + typedef std::vector<MapBase*> Container;
1.30
1.31 Container container;
1.32 -
1.33 - void add(NodeMapBase& map_base) {
1.34 +
1.35 +public:
1.36 +
1.37 + NodeMapRegistry(Graph g) : graph(&g) {}
1.38 +
1.39 + void add(MapBase& map_base) {
1.40 if (map_base.graph) {
1.41 map_base.graph->node_maps.erase(map_base);
1.42 }
1.43 container.push_back(&map_base);
1.44 - map_base.graph = this;
1.45 + map_base.graph = graph;
1.46 map_base.graph_index = container.size()-1;
1.47 }
1.48
1.49 - void erase(NodeMapBase& map_base) {
1.50 - if (map_base.graph != this) return;
1.51 + void erase(MapBase& map_base) {
1.52 container.back()->graph_index = map_base.graph_index;
1.53 container[map_base.graph_index] = container.back();
1.54 container.pop_back();
1.55 map_base.graph = 0;
1.56 }
1.57 +
1.58
1.59 void add(Node& node) {
1.60 typename Container::iterator it;
1.61 @@ -49,7 +60,6 @@
1.62 }
1.63 }
1.64
1.65 - friend class NodeMapBase;
1.66 };
1.67
1.68 #endif