(none)
authordeba
Thu, 22 Apr 2004 20:36:21 +0000
changeset 378c3f93631cd24
parent 377 33fe0ee01dc5
child 379 a5bff2813c4d
(none)
src/work/deba/edge_map_base.h
src/work/deba/edge_map_registry.h
src/work/deba/invalid.h
src/work/deba/main.cpp
src/work/deba/map_base.h
src/work/deba/map_registry.h
src/work/deba/node_map_base.h
src/work/deba/node_map_registry.h
src/work/deba/test_graph.h
src/work/deba/vector_edge_map.h
src/work/deba/vector_map.h
     1.1 --- a/src/work/deba/edge_map_base.h	Thu Apr 22 16:36:57 2004 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,121 +0,0 @@
     1.4 -#ifndef EDGE_MAP_BASE_H
     1.5 -#define EDGE_MAP_BASE_H
     1.6 -
     1.7 -/**
     1.8 -	Template base class for implementing mapping on edges.
     1.9 -	\param The first template parameter is the Graph class. The Graph
    1.10 -		must have an \emp edge_maps member with \emp EdgeMapRegistry class.
    1.11 -	\param The second template parameter is the Edge type of the class.
    1.12 -	
    1.13 -*/
    1.14 -
    1.15 -template <typename G, typename K>
    1.16 -class EdgeMapBase {
    1.17 -
    1.18 -#include "edge_map_registry.h"
    1.19 -
    1.20 -public:
    1.21 -	typedef G Graph;
    1.22 -	friend class EdgeMapRegistry<G, K>;
    1.23 -
    1.24 -	typedef K KeyType;
    1.25 -	
    1.26 -	/** 
    1.27 -		Default constructor.
    1.28 -	*/	
    1.29 -	
    1.30 -	EdgeMapBase() : graph(0) {}
    1.31 -
    1.32 -	/** 
    1.33 -		Simple constructor to register into a graph.
    1.34 -	*/
    1.35 -	
    1.36 -	EdgeMapBase(Graph& g) : graph(&g) {
    1.37 -		graph->edge_maps.add(*this);
    1.38 -	}
    1.39 -
    1.40 -	/** 
    1.41 -		Copy constructor with registering into the map.
    1.42 -	*/	
    1.43 -	
    1.44 -	EdgeMapBase(const EdgeMapBase& copy) : graph(copy.graph) {
    1.45 -		if (graph) {
    1.46 -			graph->edge_maps.add(*this);
    1.47 -		}
    1.48 -	} 
    1.49 -	
    1.50 -	/** 
    1.51 -		Assign operator.
    1.52 -	*/	
    1.53 -
    1.54 -	const EdgeMapBase& operator=(const EdgeMapBase& copy) {
    1.55 -		if (graph) {
    1.56 -			graph.edge_maps.erase(*this);
    1.57 -		}
    1.58 -		graph = copy.graph;
    1.59 -		if (graph) {
    1.60 -			graph->edge_maps.add(*this);
    1.61 -		}
    1.62 -		
    1.63 -	}
    1.64 -	
    1.65 -
    1.66 -	/** 
    1.67 -		Destructor.
    1.68 -	*/	
    1.69 -
    1.70 -	virtual ~EdgeMapBase() {
    1.71 -		if (graph) {
    1.72 -			graph.edge_maps.erase(*this);
    1.73 -		}
    1.74 -	}
    1.75 -	
    1.76 -protected:
    1.77 -	
    1.78 -	Graph* graph;
    1.79 -
    1.80 -	int graph_index;
    1.81 -	
    1.82 -	/**
    1.83 -		Helper function to implement the default constructor in the subclasses.
    1.84 -	*/
    1.85 -	
    1.86 -	void init() {
    1.87 -		for (typename Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
    1.88 -			add(it);
    1.89 -		}
    1.90 -	}
    1.91 -	
    1.92 -	/**
    1.93 -		Helper function to implement the destructor in the subclasses.
    1.94 -	*/
    1.95 -	
    1.96 -	void destroy() {
    1.97 -		for (typename Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
    1.98 -			erase(it);
    1.99 -		}
   1.100 -	}
   1.101 -	
   1.102 -	/** 
   1.103 -		The add member function should be overloaded in the subclasses.
   1.104 -		\e Add extends the map with the new edge.
   1.105 -	*/
   1.106 -	
   1.107 -	virtual void add(const KeyType&) = 0;
   1.108 -	
   1.109 -	/** 
   1.110 -		The erase member function should be overloaded in the subclasses.
   1.111 -		\e Erase removes the edge from the map.
   1.112 -	*/
   1.113 -	
   1.114 -	virtual void erase(const KeyType&) = 0;
   1.115 -	
   1.116 -	/**
   1.117 -		Exception class to throw at unsupported operation.
   1.118 -	*/
   1.119 -	
   1.120 -	class NotSupportedOperationException {};
   1.121 -
   1.122 -};
   1.123 -
   1.124 -#endif
     2.1 --- a/src/work/deba/edge_map_registry.h	Thu Apr 22 16:36:57 2004 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,65 +0,0 @@
     2.4 -#ifndef EDGE_MAP_REGISTRY_H
     2.5 -#define EDGE_MAP_REGISTRY_H
     2.6 -
     2.7 -#include <vector>
     2.8 -
     2.9 -template <typename G, typename K>
    2.10 -class EdgeMapRegistry;
    2.11 -
    2.12 -#include "edge_map_base.h"
    2.13 -
    2.14 -template <typename G, typename K>
    2.15 -class EdgeMapRegistry {
    2.16 -public:
    2.17 -	typedef G Graph;
    2.18 -	typedef K Edge;
    2.19 -	
    2.20 -	typedef EdgeMapBase<Graph, Edge> MapBase;
    2.21 -	friend class MapBase;
    2.22 -
    2.23 -protected:
    2.24 -	
    2.25 -	Graph* graph;
    2.26 -
    2.27 -	typedef std::vector<MapBase*> Container; 
    2.28 -	
    2.29 -	Container container;
    2.30 -
    2.31 -public:
    2.32 -
    2.33 -	EdgeMapRegistry(Graph g) : graph(&g) {}
    2.34 -
    2.35 -	void add(MapBase& map_base) {
    2.36 -		if (map_base.graph) {
    2.37 -			map_base.graph->edge_maps.erase(map_base);
    2.38 -		}
    2.39 -		container.push_back(&map_base);
    2.40 -		map_base.graph = graph;
    2.41 -		map_base.graph_index = container.size()-1;
    2.42 -	} 
    2.43 -	
    2.44 -	void erase(MapBase& map_base) {
    2.45 -		container.back()->graph_index = map_base.graph_index; 
    2.46 -		container[map_base.graph_index] = container.back();
    2.47 -		container.pop_back();
    2.48 -		map_base.graph = 0;
    2.49 -	}
    2.50 -
    2.51 -	
    2.52 -	void add(Edge& edge) {
    2.53 -		typename Container::iterator it;
    2.54 -		for (it = container.begin(); it != container.end(); ++it) {
    2.55 -			(*it)->add(edge);
    2.56 -		}
    2.57 -	}
    2.58 -	
    2.59 -	void erase(Edge& edge) {
    2.60 -		typename Container::iterator it;
    2.61 -		for (it = container.begin(); it != container.end(); ++it) {
    2.62 -			(*it)->erase(edge);
    2.63 -		}
    2.64 -	}
    2.65 -
    2.66 -};
    2.67 -
    2.68 -#endif
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/work/deba/invalid.h	Thu Apr 22 20:36:21 2004 +0000
     3.3 @@ -0,0 +1,33 @@
     3.4 +// -*- mode:C++ -*-
     3.5 +
     3.6 +#ifndef HUGO_INVALID_H
     3.7 +#define HUGO_INVALID_H
     3.8 +
     3.9 +///\file
    3.10 +///\brief Definition of INVALID.
    3.11 +
    3.12 +namespace hugo {
    3.13 +
    3.14 +  /// Dummy type to make it easier to make invalid iterators.
    3.15 +  
    3.16 +  /// See \ref INVALID, how to use it.
    3.17 +  
    3.18 +  struct Invalid {};
    3.19 +  
    3.20 +  /// Invalid iterators.
    3.21 +  
    3.22 +  /// \ref Invalid is a global type that converts to each iterator
    3.23 +  /// in such a way that the value of the target iterator will be invalid.
    3.24 +
    3.25 +  // It is also used to convert the \c INVALID constant to the
    3.26 +  // node iterator that makes is possible to write 
    3.27 +
    3.28 +  //extern Invalid INVALID;
    3.29 +
    3.30 +  //const Invalid &INVALID = *(Invalid *)0;
    3.31 +  const Invalid INVALID = Invalid();
    3.32 +
    3.33 +};
    3.34 +
    3.35 +#endif
    3.36 +  
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/work/deba/main.cpp	Thu Apr 22 20:36:21 2004 +0000
     4.3 @@ -0,0 +1,15 @@
     4.4 +#include <iostream>
     4.5 +#include "test_graph.h"
     4.6 +
     4.7 +using namespace std;
     4.8 +using namespace hugo;
     4.9 +
    4.10 +
    4.11 +int main() {
    4.12 +	ListGraph g;
    4.13 +	ListGraph::NodeMap<int> map(g);
    4.14 +	ListGraph::Node node = g.addNode();
    4.15 +	map[node] = 12;	
    4.16 +	return 0;
    4.17 +}
    4.18 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/work/deba/map_base.h	Thu Apr 22 20:36:21 2004 +0000
     5.3 @@ -0,0 +1,132 @@
     5.4 +#ifndef MAP_BASE_H
     5.5 +#define MAP_BASE_H
     5.6 +
     5.7 +/**
     5.8 +	Template base class for implementing mapping on nodes.
     5.9 +	\param The first template parameter is the Graph class. The Graph
    5.10 +		must have an \emp node_maps member with \emp MapRegistry class.
    5.11 +	\param The second template parameter is the  type of the class.
    5.12 +	
    5.13 +*/
    5.14 +
    5.15 +
    5.16 +namespace hugo {
    5.17 +	template <typename G, typename K, typename KIt>
    5.18 +	class MapBase;
    5.19 +}
    5.20 +
    5.21 +#include "map_registry.h"
    5.22 +
    5.23 +namespace hugo {
    5.24 +
    5.25 +	template <typename G, typename K, typename KIt>
    5.26 +	class MapBase {
    5.27 +	public:
    5.28 +		typedef G Graph;
    5.29 +		typedef MapRegistry<G, K, KIt> Registry;
    5.30 +		typedef K KeyType;
    5.31 +		typedef KIt KeyIt;
    5.32 +	
    5.33 +		friend class Registry;
    5.34 +		
    5.35 +		/** 
    5.36 +			Default constructor.
    5.37 +		*/	
    5.38 +		
    5.39 +		MapBase() : registry(0) {}
    5.40 +
    5.41 +		/** 
    5.42 +			Simple constructor to register into a graph registry.
    5.43 +		*/
    5.44 +	
    5.45 +		MapBase(Registry& r) : registry(0) {
    5.46 +			registry->add(*this);
    5.47 +		}
    5.48 +
    5.49 +		/** 
    5.50 +			Copy constructor with registering into the map.
    5.51 +		*/	
    5.52 +	
    5.53 +		MapBase(const MapBase& copy) : registry(0) {
    5.54 +			if (registry) {
    5.55 +				registry->add(*this);
    5.56 +			}
    5.57 +		} 
    5.58 +	
    5.59 +		/** 
    5.60 +			Assign operator.
    5.61 +		*/	
    5.62 +
    5.63 +		const MapBase& operator=(const MapBase& copy) {
    5.64 +			if (registry) {
    5.65 +				registry->erase(*this);
    5.66 +			}
    5.67 +			registry = copy.registry;
    5.68 +			if (registry) {
    5.69 +				registry->add(*this);
    5.70 +			}
    5.71 +		}
    5.72 +	
    5.73 +
    5.74 +		/** 
    5.75 +			Destructor.
    5.76 +		*/		
    5.77 +
    5.78 +		virtual ~MapBase() {
    5.79 +			if (registry) {
    5.80 +				registry->erase(*this);
    5.81 +			}
    5.82 +		}
    5.83 +	
    5.84 +	protected:
    5.85 +		
    5.86 +		Registry* registry;
    5.87 +
    5.88 +		int registry_index;
    5.89 +	
    5.90 +		/**
    5.91 +			Helper function to implement the default constructor in the subclasses.
    5.92 +		*/
    5.93 +	
    5.94 +		virtual void init(Graph& g) {
    5.95 +
    5.96 +			for (KeyIt it(g); g.valid(it); g.next(it)) {
    5.97 +				add(it);
    5.98 +			}
    5.99 +		}
   5.100 +	
   5.101 +		/**
   5.102 +			Helper function to implement the destructor in the subclasses.
   5.103 +		*/
   5.104 +	
   5.105 +		virtual void destroy(Graph& g) {
   5.106 +			for (KeyIt it(g); g.valid(it); g.next(it)) {
   5.107 +				erase(it);
   5.108 +			}
   5.109 +		}
   5.110 +	
   5.111 +		/** 
   5.112 +			The add member function should be overloaded in the subclasses.
   5.113 +			\e Add extends the map with the new node.
   5.114 +		*/
   5.115 +	
   5.116 +		virtual void add(const KeyType&) = 0;
   5.117 +	
   5.118 +		/** 
   5.119 +			The erase member function should be overloaded in the subclasses.
   5.120 +			\e Erase removes the node from the map.
   5.121 +		*/
   5.122 +	
   5.123 +		virtual void erase(const KeyType&) = 0;
   5.124 +	
   5.125 +		/**
   5.126 +			Exception class to throw at unsupported operation.
   5.127 +		*/
   5.128 +	
   5.129 +		class NotSupportedOperationException {};
   5.130 +
   5.131 +	};
   5.132 +	
   5.133 +}
   5.134 +
   5.135 +#endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/work/deba/map_registry.h	Thu Apr 22 20:36:21 2004 +0000
     6.3 @@ -0,0 +1,94 @@
     6.4 +#ifndef MAP_REGISTRY_H
     6.5 +#define MAP_REGISTRY_H
     6.6 +
     6.7 +#include <vector>
     6.8 +
     6.9 +
    6.10 +namespace hugo {
    6.11 +	template <typename G, typename K, typename KIt>
    6.12 +	class MapRegistry;
    6.13 +}
    6.14 +
    6.15 +#include "map_base.h"
    6.16 +
    6.17 +namespace hugo {
    6.18 +
    6.19 +	template <typename G, typename K, typename KIt>
    6.20 +	class MapRegistry {
    6.21 +	public:
    6.22 +		typedef G Graph;
    6.23 +		typedef K Key;
    6.24 +		typedef KIt KeyIt;
    6.25 +	
    6.26 +		typedef MapBase<Graph, Key, KIt> Map;
    6.27 +		friend class Base;
    6.28 +	
    6.29 +	protected:
    6.30 +	
    6.31 +		typedef std::vector<Map*> Container; 
    6.32 +	  Container container;
    6.33 +
    6.34 +		Graph* graph;		
    6.35 +		
    6.36 +		
    6.37 +	public:
    6.38 +	
    6.39 +		MapRegistry(Graph& g) : container(0), graph(&g) {}
    6.40 +				
    6.41 +		~MapRegistry() {
    6.42 +			typename Container::iterator it;
    6.43 +			for (it = container.begin(); it != container.end(); ++it) {
    6.44 +				(*it)->destroy(*graph);
    6.45 +				(*it)->registry = 0;
    6.46 +			}
    6.47 +		}
    6.48 +	
    6.49 +	private:
    6.50 +		MapRegistry(const MapRegistry& ) {}
    6.51 +		MapRegistry& operator=(const MapRegistry& ) {}
    6.52 +	
    6.53 +	public:
    6.54 +	
    6.55 +		void add(Map& map) {
    6.56 +			if (map.registry) {
    6.57 +				map.registry->erase(map);
    6.58 +			}
    6.59 +			container.push_back(&map);
    6.60 +			map.registry = this;
    6.61 +			map.registry_index = container.size()-1;
    6.62 +			map.init(*graph);
    6.63 +		} 
    6.64 +	
    6.65 +		void erase(Map& map_base) {
    6.66 +			map_base.destroy(*graph);
    6.67 +			container.back()->registry_index = map_base.registry_index; 
    6.68 +			container[map_base.registry_index] = container.back();
    6.69 +			container.pop_back();
    6.70 +			map_base.registry = 0;
    6.71 +		}
    6.72 +	
    6.73 +		
    6.74 +		void add(Key& key) {
    6.75 +			typename Container::iterator it;
    6.76 +			for (it = container.begin(); it != container.end(); ++it) {
    6.77 +				(*it)->add(key);
    6.78 +			}
    6.79 +		}	
    6.80 +		
    6.81 +		void erase(Key& key) {
    6.82 +			typename Container::iterator it;
    6.83 +			for (it = container.begin(); it != container.end(); ++it) {
    6.84 +				(*it)->erase(key);
    6.85 +			}
    6.86 +		}
    6.87 +
    6.88 +		Graph& getGraph() {
    6.89 +			return *graph;
    6.90 +		}
    6.91 +
    6.92 +
    6.93 +	};
    6.94 +
    6.95 +}
    6.96 +
    6.97 +#endif
     7.1 --- a/src/work/deba/node_map_base.h	Thu Apr 22 16:36:57 2004 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,121 +0,0 @@
     7.4 -#ifndef NODE_MAP_BASE_H
     7.5 -#define NODE_MAP_BASE_H
     7.6 -
     7.7 -/**
     7.8 -	Template base class for implementing mapping on nodes.
     7.9 -	\param The first template parameter is the Graph class. The Graph
    7.10 -		must have an \emp node_maps member with \emp NodeMapRegistry class.
    7.11 -	\param The second template parameter is the Node type of the class.
    7.12 -	
    7.13 -*/
    7.14 -
    7.15 -template <typename G, typename K>
    7.16 -class NodeMapBase {
    7.17 -
    7.18 -#include "node_map_registry.h"
    7.19 -
    7.20 -public:
    7.21 -	typedef G Graph;
    7.22 -	friend class NodeMapRegistry<G, K>;
    7.23 -
    7.24 -	typedef K KeyType;
    7.25 -	
    7.26 -	/** 
    7.27 -		Default constructor.
    7.28 -	*/	
    7.29 -	
    7.30 -	NodeMapBase() : graph(0) {}
    7.31 -
    7.32 -	/** 
    7.33 -		Simple constructor to register into a graph.
    7.34 -	*/
    7.35 -	
    7.36 -	NodeMapBase(Graph& g) : graph(&g) {
    7.37 -		graph->node_maps.add(*this);
    7.38 -	}
    7.39 -
    7.40 -	/** 
    7.41 -		Copy constructor with registering into the map.
    7.42 -	*/	
    7.43 -	
    7.44 -	NodeMapBase(const NodeMapBase& copy) : graph(copy.graph) {
    7.45 -		if (graph) {
    7.46 -			graph->node_maps.add(*this);
    7.47 -		}
    7.48 -	} 
    7.49 -	
    7.50 -	/** 
    7.51 -		Assign operator.
    7.52 -	*/	
    7.53 -
    7.54 -	const NodeMapBase& operator=(const NodeMapBase& copy) {
    7.55 -		if (graph) {
    7.56 -			graph.node_maps.erase(*this);
    7.57 -		}
    7.58 -		graph = copy.graph;
    7.59 -		if (graph) {
    7.60 -			graph->node_maps.add(*this);
    7.61 -		}
    7.62 -		
    7.63 -	}
    7.64 -	
    7.65 -
    7.66 -	/** 
    7.67 -		Destructor.
    7.68 -	*/	
    7.69 -
    7.70 -	virtual ~NodeMapBase() {
    7.71 -		if (graph) {
    7.72 -			graph->node_maps.erase(*this);
    7.73 -		}
    7.74 -	}
    7.75 -	
    7.76 -protected:
    7.77 -	
    7.78 -	Graph* graph;
    7.79 -
    7.80 -	int graph_index;
    7.81 -	
    7.82 -	/**
    7.83 -		Helper function to implement the default constructor in the subclasses.
    7.84 -	*/
    7.85 -	
    7.86 -	void init() {
    7.87 -		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    7.88 -			add(it);
    7.89 -		}
    7.90 -	}
    7.91 -	
    7.92 -	/**
    7.93 -		Helper function to implement the destructor in the subclasses.
    7.94 -	*/
    7.95 -	
    7.96 -	void destroy() {
    7.97 -		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    7.98 -			erase(it);
    7.99 -		}
   7.100 -	}
   7.101 -	
   7.102 -	/** 
   7.103 -		The add member function should be overloaded in the subclasses.
   7.104 -		\e Add extends the map with the new node.
   7.105 -	*/
   7.106 -	
   7.107 -	virtual void add(const KeyType&) = 0;
   7.108 -	
   7.109 -	/** 
   7.110 -		The erase member function should be overloaded in the subclasses.
   7.111 -		\e Erase removes the node from the map.
   7.112 -	*/
   7.113 -	
   7.114 -	virtual void erase(const KeyType&) = 0;
   7.115 -	
   7.116 -	/**
   7.117 -		Exception class to throw at unsupported operation.
   7.118 -	*/
   7.119 -	
   7.120 -	class NotSupportedOperationException {};
   7.121 -
   7.122 -};
   7.123 -
   7.124 -#endif
     8.1 --- a/src/work/deba/node_map_registry.h	Thu Apr 22 16:36:57 2004 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,65 +0,0 @@
     8.4 -#ifndef NODE_MAP_REGISTRY_H
     8.5 -#define NODE_MAP_REGISTRY_H
     8.6 -
     8.7 -#include <vector>
     8.8 -
     8.9 -template <typename G, typename K>
    8.10 -class NodeMapRegistry;
    8.11 -
    8.12 -#include "node_map_base.h"
    8.13 -
    8.14 -template <typename G, typename K>
    8.15 -class NodeMapRegistry {
    8.16 -public:
    8.17 -	typedef G Graph;
    8.18 -	typedef K Node;
    8.19 -	
    8.20 -	typedef NodeMapBase<Graph, Node> MapBase;
    8.21 -	friend class MapBase;
    8.22 -
    8.23 -protected:
    8.24 -	
    8.25 -	Graph* graph;
    8.26 -
    8.27 -	typedef std::vector<MapBase*> Container; 
    8.28 -	
    8.29 -	Container container;
    8.30 -
    8.31 -public:
    8.32 -
    8.33 -	NodeMapRegistry(Graph g) : graph(&g) {}
    8.34 -
    8.35 -	void add(MapBase& map_base) {
    8.36 -		if (map_base.graph) {
    8.37 -			map_base.graph->node_maps.erase(map_base);
    8.38 -		}
    8.39 -		container.push_back(&map_base);
    8.40 -		map_base.graph = graph;
    8.41 -		map_base.graph_index = container.size()-1;
    8.42 -	} 
    8.43 -	
    8.44 -	void erase(MapBase& map_base) {
    8.45 -		container.back()->graph_index = map_base.graph_index; 
    8.46 -		container[map_base.graph_index] = container.back();
    8.47 -		container.pop_back();
    8.48 -		map_base.graph = 0;
    8.49 -	}
    8.50 -
    8.51 -	
    8.52 -	void add(Node& node) {
    8.53 -		typename Container::iterator it;
    8.54 -		for (it = container.begin(); it != container.end(); ++it) {
    8.55 -			(*it)->add(node);
    8.56 -		}
    8.57 -	}
    8.58 -	
    8.59 -	void erase(Node& node) {
    8.60 -		typename Container::iterator it;
    8.61 -		for (it = container.begin(); it != container.end(); ++it) {
    8.62 -			(*it)->erase(node);
    8.63 -		}
    8.64 -	}
    8.65 -
    8.66 -};
    8.67 -
    8.68 -#endif
     9.1 --- a/src/work/deba/test_graph.h	Thu Apr 22 16:36:57 2004 +0000
     9.2 +++ b/src/work/deba/test_graph.h	Thu Apr 22 20:36:21 2004 +0000
     9.3 @@ -7,10 +7,6 @@
     9.4  
     9.5  #include "invalid.h"
     9.6  
     9.7 -#include "edge_map_registry.h"
     9.8 -#include "node_map_registry.h"
     9.9 -#include "edge_map_base.h"
    9.10 -#include "node_map_base.h"
    9.11  #include "vector_map.h"
    9.12  
    9.13  namespace hugo {
    9.14 @@ -42,22 +38,26 @@
    9.15   
    9.16    private:
    9.17  
    9.18 -		NodeMapRegistry<ListGraph, Node> node_maps(*this);
    9.19 -		EdgeMapRegistry<ListGraph, Edge> edge_maps(*this);
    9.20 +		typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
    9.21 +		NodeMapRegistry node_maps;
    9.22 +		
    9.23 +		typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
    9.24 +		EdgeMapRegistry edge_maps;
    9.25   
    9.26  	public:
    9.27   
    9.28  
    9.29      template <typename T>
    9.30 -    class NodeMap : public VectorMap<ListGraph, Node, T, NodeMapBase> {
    9.31 +    class NodeMap : public VectorMap<ListGraph, Node, NodeIt, T> {
    9.32  		public:
    9.33 -			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, T, NodeMapBase>(g) {}
    9.34 +			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, NodeIt, T>(g.node_maps) {}
    9.35  		};
    9.36  		
    9.37 -		EdgeMapRegistry<ListGraph, Edge> edge_maps;
    9.38 -
    9.39      template <typename T>
    9.40 -    class EdgeMap : public VectorMap<ListGraph, Edge, T, EdgeMapBase> {};
    9.41 +    class EdgeMap : public VectorMap<ListGraph, Edge, EdgeIt, T> {
    9.42 +		public:
    9.43 +			EdgeMap(ListGraph& g) : VectorMap<ListGraph, Edge, EdgeIt, T>(g.edge_maps) {}
    9.44 +		};
    9.45  
    9.46  
    9.47      int node_id;
    9.48 @@ -215,7 +215,8 @@
    9.49  
    9.50      /* default constructor */
    9.51  
    9.52 -    ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
    9.53 +    ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0),
    9.54 +			edge_maps(*this), node_maps(*this) { }
    9.55      
    9.56      ~ListGraph() { 
    9.57        while (first<NodeIt>().valid()) erase(first<NodeIt>());
    10.1 --- a/src/work/deba/vector_edge_map.h	Thu Apr 22 16:36:57 2004 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,29 +0,0 @@
    10.4 -#ifndef VECTOR_EDGE_MAP_H
    10.5 -#define VECTOR_EDGE_MAP_H
    10.6 -
    10.7 -#include <vector>
    10.8 -
    10.9 -#include "edge_map_base.h"
   10.10 -
   10.11 -template <typename G, typename E, typename V> 
   10.12 -class VectorEdgeMap : public EdgeMapBase<G, E>{
   10.13 -public:
   10.14 -	typedef V ValueType;
   10.15 -	
   10.16 -	VectorEdgeMap(Graph& g) : EdgeMapBase<G, E>(g) {}
   10.17 -	
   10.18 -	void add(const E& edge) {
   10.19 -		if (edge->id >= container.size()) {
   10.20 -			container.resize(edge->id);
   10.21 -		}
   10.22 -	}
   10.23 -	
   10.24 -	void erase(const E&) {}
   10.25 -
   10.26 -private:
   10.27 -	typedef vector<ValueType> Container;
   10.28 -	
   10.29 -	Container container;
   10.30 -}
   10.31 -
   10.32 -#endif
   10.33 \ No newline at end of file
    11.1 --- a/src/work/deba/vector_map.h	Thu Apr 22 16:36:57 2004 +0000
    11.2 +++ b/src/work/deba/vector_map.h	Thu Apr 22 20:36:21 2004 +0000
    11.3 @@ -2,49 +2,57 @@
    11.4  #define VECTOR_MAP_H
    11.5  
    11.6  #include <vector>
    11.7 +#include <iostream>
    11.8  
    11.9 -template <typename G, typename K, typename V, template <typename, typename> class MapBase > 
   11.10 -class VectorMap : public MapBase<G, K> {
   11.11 -public:
   11.12 -	typedef V ValueType;
   11.13 +#include "map_base.h"
   11.14 +
   11.15 +namespace hugo {
   11.16 +
   11.17 +	template <typename G, typename K, typename KIt, typename V> 
   11.18 +	class VectorMap : public MapBase<G, K, KIt> {
   11.19 +	public:
   11.20 +		typedef V ValueType;
   11.21  	
   11.22 -	VectorMap() {}
   11.23 -	VectorMap(G& g) : MapBase<G, K>(g) {
   11.24 -		init();
   11.25 -	}
   11.26 +		VectorMap() {}
   11.27 +		VectorMap(typename MapBase<G, K, KIt>::Registry& r) : MapBase<G, K, KIt>(r) {}
   11.28  	
   11.29 -	~VectorMap() {
   11.30 -//		destroy();
   11.31 -	} 
   11.32  	
   11.33 -	ValueType& operator[](const K& key) {
   11.34 -		return container[key->id];
   11.35 -	} 
   11.36 +		ValueType& operator[](const K& key) {
   11.37 +			int id = registry->getGraph().id(key);
   11.38 +			return container[id];
   11.39 +		} 
   11.40  	
   11.41 -	const ValueType& operator[](const K& key) const {
   11.42 -		return container[key->id];
   11.43 -	}
   11.44 +		const ValueType& operator[](const K& key) const {
   11.45 +			int id = registry->getGraph().id(key);
   11.46 +			return container[id];
   11.47 +		}
   11.48  	
   11.49 -	const ValueType& get(const K& key) const {
   11.50 -		return container[key->id];
   11.51 -	} 
   11.52 +		const ValueType& get(const K& key) const {
   11.53 +			int id = registry->getGraph().id(key);
   11.54 +			return container[id];
   11.55 +		} 
   11.56  	
   11.57 -	void set(const K& key, const ValueType& val) {
   11.58 -		container[key->id] = val;
   11.59 -	}
   11.60 +		void set(const K& key, const ValueType& val) {
   11.61 +			int id = registry->getGraph().id(key);
   11.62 +			container[id] = val;
   11.63 +		}
   11.64  	
   11.65 -	void add(const K& key) {
   11.66 -		if (key->id() >= container.size()) {
   11.67 -			container.resize(key->id() + 1);
   11.68 +		void add(const K& key) {
   11.69 +			int id = registry->getGraph().id(key);
   11.70 +			std::cerr << id << std::endl;
   11.71 +			if (id >= container.size()) {
   11.72 +				container.resize(id + 1);
   11.73 +			}
   11.74  		}
   11.75 -	}
   11.76  	
   11.77 -	void erase(const K& key) {}
   11.78 +		void erase(const K& key) {}
   11.79  
   11.80 -private:
   11.81 -	typedef std::vector<ValueType> Container;
   11.82 +	private:
   11.83 +		typedef std::vector<ValueType> Container;
   11.84  	
   11.85 -	Container container;
   11.86 -};
   11.87 +		Container container;
   11.88 +	};
   11.89 +
   11.90 +}
   11.91  
   11.92  #endif