# HG changeset patch # User deba # Date 1082117717 0 # Node ID 6e1b7efa577f6df3d853575b4e8c6ec31ed78ee1 # Parent 8ff3b3e0547843160a181e59e146ae0ad95045ba diff -r 8ff3b3e05478 -r 6e1b7efa577f src/work/deba/edge_map_registry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/deba/edge_map_registry.h Fri Apr 16 12:15:17 2004 +0000 @@ -0,0 +1,53 @@ +#ifndef EDGE_MAP_REGISTRY_H +#define EDGE_MAP_REGISTRY_H + +#include + +template +class EdgeMapRegistry { +public: + typedef G Graph; + typedef E Edge + + typedef EdgeMapBase EdgeMapBase; + +protected: + typedef std::vector Container; + + Container container; + + void add(EdgeMapBase& map_base) { + if (map_base.graph) { + map_base.graph->edge_maps.erase(map_base); + } + container.push_back(&map_base); + map_base.graph = this; + map_base.graph_index = container.size()-1; + } + + void erase(EdgeMapBase& map_base) { + if (map_base.graph != this) return; + container.back()->graph_index = map_base.graph_index; + container[map_base.graph_index] = container.back(); + container.pop_back(); + map_base.graph = 0; + } + + void addEdge(Edge& edge) { + typename Container::iterator it; + for (it = container.begin(); it != container.end(); ++it) { + (*it)->add(edge); + } + } + + void eraseEdge(Edge& edge) { + typename Container::iterator it; + for (it = container.begin(); it != container.end(); ++it) { + (*it)->erase(edge); + } + } + + friend class EdgeMapBase; +}; + +#endif diff -r 8ff3b3e05478 -r 6e1b7efa577f src/work/deba/node_map_registry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/deba/node_map_registry.h Fri Apr 16 12:15:17 2004 +0000 @@ -0,0 +1,53 @@ +#ifndef NODE_MAP_REGISTRY_H +#define NODE_MAP_REGISTRY_H + +#include + +template +class NodeMapRegistry { +public: + typedef G Graph; + typedef E Node + + typedef NodeMapBase NodeMapBase; + +protected: + typedef std::vector Container; + + Container container; + + void add(NodeMapBase& map_base) { + if (map_base.graph) { + map_base.graph->node_maps.erase(map_base); + } + container.push_back(&map_base); + map_base.graph = this; + map_base.graph_index = container.size()-1; + } + + void erase(NodeMapBase& map_base) { + if (map_base.graph != this) return; + container.back()->graph_index = map_base.graph_index; + container[map_base.graph_index] = container.back(); + container.pop_back(); + map_base.graph = 0; + } + + void addNode(Node& node) { + typename Container::iterator it; + for (it = container.begin(); it != container.end(); ++it) { + (*it)->add(node); + } + } + + void eraseNode(Node& node) { + typename Container::iterator it; + for (it = container.begin(); it != container.end(); ++it) { + (*it)->erase(node); + } + } + + friend class NodeMapBase; +}; + +#endif