[Lemon-commits] [lemon_svn] deba: r456 - hugo/trunk/src/work/deba

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:39:33 CET 2006


Author: deba
Date: Fri Apr 16 14:15:17 2004
New Revision: 456

Added:
   hugo/trunk/src/work/deba/edge_map_registry.h
   hugo/trunk/src/work/deba/node_map_registry.h

Log:


Added: hugo/trunk/src/work/deba/edge_map_registry.h
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/deba/edge_map_registry.h	Fri Apr 16 14:15:17 2004
@@ -0,0 +1,53 @@
+#ifndef EDGE_MAP_REGISTRY_H
+#define EDGE_MAP_REGISTRY_H
+
+#include <vector>
+
+template <typename G, typename E>
+class EdgeMapRegistry {
+public:
+	typedef G Graph;
+	typedef E Edge
+	
+	typedef EdgeMapBase<Graph, Edge> EdgeMapBase;
+
+protected:
+	typedef std::vector<EdgeMapBase*> 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

Added: hugo/trunk/src/work/deba/node_map_registry.h
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/deba/node_map_registry.h	Fri Apr 16 14:15:17 2004
@@ -0,0 +1,53 @@
+#ifndef NODE_MAP_REGISTRY_H
+#define NODE_MAP_REGISTRY_H
+
+#include <vector>
+
+template <typename G, typename E>
+class NodeMapRegistry {
+public:
+	typedef G Graph;
+	typedef E Node
+	
+	typedef NodeMapBase<Graph, Node> NodeMapBase;
+
+protected:
+	typedef std::vector<NodeMapBase*> 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



More information about the Lemon-commits mailing list