(none)
authordeba
Fri, 16 Apr 2004 12:15:17 +0000
changeset 3376e1b7efa577f
parent 336 8ff3b3e05478
child 338 e8725f30dd98
(none)
src/work/deba/edge_map_registry.h
src/work/deba/node_map_registry.h
     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
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/work/deba/node_map_registry.h	Fri Apr 16 12:15:17 2004 +0000
     2.3 @@ -0,0 +1,53 @@
     2.4 +#ifndef NODE_MAP_REGISTRY_H
     2.5 +#define NODE_MAP_REGISTRY_H
     2.6 +
     2.7 +#include <vector>
     2.8 +
     2.9 +template <typename G, typename E>
    2.10 +class NodeMapRegistry {
    2.11 +public:
    2.12 +	typedef G Graph;
    2.13 +	typedef E Node
    2.14 +	
    2.15 +	typedef NodeMapBase<Graph, Node> NodeMapBase;
    2.16 +
    2.17 +protected:
    2.18 +	typedef std::vector<NodeMapBase*> Container; 
    2.19 +	
    2.20 +	Container container;
    2.21 +	
    2.22 +	void add(NodeMapBase& map_base) {
    2.23 +		if (map_base.graph) {
    2.24 +			map_base.graph->node_maps.erase(map_base);
    2.25 +		}
    2.26 +		container.push_back(&map_base);
    2.27 +		map_base.graph = this;
    2.28 +		map_base.graph_index = container.size()-1;
    2.29 +	} 
    2.30 +	
    2.31 +	void erase(NodeMapBase& map_base) {
    2.32 +		if (map_base.graph != this) return;
    2.33 +		container.back()->graph_index = map_base.graph_index; 
    2.34 +		container[map_base.graph_index] = container.back();
    2.35 +		container.pop_back();
    2.36 +		map_base.graph = 0;
    2.37 +	}
    2.38 +	
    2.39 +	void addNode(Node& node) {
    2.40 +		typename Container::iterator it;
    2.41 +		for (it = container.begin(); it != container.end(); ++it) {
    2.42 +			(*it)->add(node);
    2.43 +		}
    2.44 +	}
    2.45 +	
    2.46 +	void eraseNode(Node& node) {
    2.47 +		typename Container::iterator it;
    2.48 +		for (it = container.begin(); it != container.end(); ++it) {
    2.49 +			(*it)->erase(node);
    2.50 +		}
    2.51 +	}
    2.52 +
    2.53 +	friend class NodeMapBase;
    2.54 +};
    2.55 +
    2.56 +#endif