(none)
authordeba
Thu, 13 May 2004 08:20:39 +0000
changeset 6276cc21a9c9fda
parent 626 0015642b0990
child 628 a3a53d7cedc2
(none)
src/work/deba/array_map_factory.h
src/work/deba/main.cpp
src/work/deba/map_base.h
src/work/deba/map_registry.h
src/work/deba/test_graph.h
src/work/deba/vector_map_factory.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/deba/array_map_factory.h	Thu May 13 08:20:39 2004 +0000
     1.3 @@ -0,0 +1,123 @@
     1.4 +#ifndef ARRAY_MAP_H
     1.5 +#define ARRAY_MAP_H
     1.6 +
     1.7 +#include <memory>
     1.8 +
     1.9 +#include "map_base.h"
    1.10 +
    1.11 +#include <iostream>
    1.12 +using namespace std;
    1.13 +
    1.14 +namespace hugo {
    1.15 +	
    1.16 +	template <typename G, typename K, typename KIt>
    1.17 +	class ArrayMapFactory {
    1.18 +	
    1.19 +	
    1.20 +	public:
    1.21 +		
    1.22 +		typedef G Graph;
    1.23 +		typedef K Key;
    1.24 +		typedef KIt KeyIt;
    1.25 +		
    1.26 +		template <typename V, typename A = allocator<V> > 
    1.27 +		class Map : public MapBase<G, K, KIt> {
    1.28 +		public:
    1.29 +			typedef V Value;
    1.30 +			typedef typename _Alloc_traits<V, A>::_Alloc_type _Alloc_type;
    1.31 +
    1.32 +	
    1.33 +			Map() : values(0), capacity(0) {}
    1.34 +			
    1.35 +			Map(Graph& g, MapRegistry<G, K, KIt>& r) 
    1.36 +				: MapBase<G, K, KIt>(g, r) {
    1.37 +				int max_id = -1;
    1.38 +				for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
    1.39 +					int id = graph->id(it);
    1.40 +					if (id > max_id) {
    1.41 +						max_id = id;
    1.42 +					}				
    1.43 +				}
    1.44 +				if (max_id == -1) {
    1.45 +					capacity = 0;
    1.46 +					values = 0;
    1.47 +					return;
    1.48 +				}
    1.49 +				int capacity = 1;
    1.50 +				while (capacity <= max_id) {
    1.51 +					capacity <<= 1;
    1.52 +				}
    1.53 +				Value* values = reinterpret_cast<Value*>(new char[capacity*sizeof(Value)]);
    1.54 +				for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
    1.55 +					int id = graph->id(it);
    1.56 +					new(&(values[id])) Value();
    1.57 +				}								
    1.58 +				cerr << capacity << endl;	
    1.59 +			}
    1.60 +				
    1.61 +			virtual ~Map() {
    1.62 +				destroy();
    1.63 +				delete[] reinterpret_cast<char*>(values);
    1.64 +				values = 0;
    1.65 +				capacity = 0;
    1.66 +			}
    1.67 +	
    1.68 +	
    1.69 +			Value& operator[](const K& key) {
    1.70 +				int id = graph->id(key);
    1.71 +				return values[id];
    1.72 +			} 
    1.73 +		
    1.74 +			const Value& operator[](const K& key) const {
    1.75 +				int id = graph->id(key);
    1.76 +				return values[id];
    1.77 +			}
    1.78 +	
    1.79 +			const Value& get(const K& key) const {
    1.80 +				int id = graph->id(key);
    1.81 +				return values[id];
    1.82 +			} 
    1.83 +		
    1.84 +			void set(const K& key, const Value& val) {
    1.85 +				int id = graph->id(key);
    1.86 +				values[id] = val;
    1.87 +			}
    1.88 +		
    1.89 +			void add(const K& key) {
    1.90 +				cerr << capacity << endl;
    1.91 +				int id = graph->id(key);
    1.92 +				if (id >= capacity) {
    1.93 +					int new_capacity = (capacity == 0 ? 1 : capacity);
    1.94 +					while (new_capacity <= id) {
    1.95 +						new_capacity <<= 1;
    1.96 +					}
    1.97 +					Value* new_values = reinterpret_cast<Value*>(new char[new_capacity*sizeof(Value)]);;
    1.98 +					for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
    1.99 +						int jd = graph->id(it);
   1.100 +						if (id != jd) {
   1.101 +							new(&(new_values[jd])) Value(values[jd]);
   1.102 +						}
   1.103 +					}
   1.104 +					if (capacity != 0) delete[] reinterpret_cast<char *>(values);
   1.105 +					values = new_values;
   1.106 +					capacity = new_capacity;
   1.107 +				}
   1.108 +				cerr << id << ' ' << capacity << endl;
   1.109 +				new(&(values[id])) Value();
   1.110 +			}
   1.111 +		
   1.112 +			void erase(const K& key) {
   1.113 +				int id = graph->id(key);
   1.114 +				values[id].~Value();
   1.115 +			}
   1.116 +	
   1.117 +		private:
   1.118 +			int capacity;
   1.119 +			Value* values;
   1.120 +								
   1.121 +		};
   1.122 +		
   1.123 +	};
   1.124 +}
   1.125 +
   1.126 +#endif
     2.1 --- a/src/work/deba/main.cpp	Wed May 12 14:07:00 2004 +0000
     2.2 +++ b/src/work/deba/main.cpp	Thu May 13 08:20:39 2004 +0000
     2.3 @@ -7,18 +7,18 @@
     2.4  
     2.5  
     2.6  int main() {
     2.7 -	ListGraph g;
     2.8 -	for (int i = 0; i < 3; ++i) {
     2.9 -		ListGraph::Node node = g.addNode();
    2.10 -	}
    2.11 -	ListGraph::NodeMapFactory::Map<int> map(g, g.node_maps);
    2.12 -	for (int i = 0; i < 10; ++i) {
    2.13 -		ListGraph::Node node = g.addNode();
    2.14 -		map[node] = rand()%100;
    2.15 -	}
    2.16 -	for (ListGraph::NodeIt it(g); g.valid(it); g.next(it)) {
    2.17 -		cout << map[it] << endl;
    2.18 -	}
    2.19 -	return 0;
    2.20 +  ListGraph g;
    2.21 +  for (int i = 0; i < 10; ++i) {
    2.22 +    ListGraph::Node node = g.addNode();
    2.23 +  }
    2.24 +  ListGraph::NodeMapFactory::Map<int> map(g, g.node_maps);
    2.25 +  for (int i = 0; i < 10; ++i) {
    2.26 +    ListGraph::Node node = g.addNode();
    2.27 +    map[node] = rand()%100;
    2.28 +  }
    2.29 +  for (ListGraph::NodeIt it(g); g.valid(it); g.next(it)) {
    2.30 +    cout << map[it] << endl;
    2.31 +  }
    2.32 +  return 0;
    2.33  }
    2.34  
     3.1 --- a/src/work/deba/map_base.h	Wed May 12 14:07:00 2004 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,133 +0,0 @@
     3.4 -#ifndef MAP_BASE_H
     3.5 -#define MAP_BASE_H
     3.6 -
     3.7 -using namespace std;
     3.8 -
     3.9 -/**
    3.10 -	Template base class for implementing mapping on nodes and edges.
    3.11 -	\param The first template parameter is the Graph class.
    3.12 -	\param The second template parameter is the key type.
    3.13 -	\param The third template parameter is an iterator on
    3.14 -		the keys.
    3.15 -*/
    3.16 -
    3.17 -
    3.18 -namespace hugo {
    3.19 -	template <typename G, typename K, typename KIt>
    3.20 -	class MapBase;
    3.21 -}
    3.22 -
    3.23 -#include "map_registry.h"
    3.24 -
    3.25 -namespace hugo {
    3.26 -
    3.27 -	template <typename G, typename K, typename KIt>
    3.28 -	class MapBase {
    3.29 -	public:
    3.30 -		typedef G Graph;
    3.31 -		typedef MapRegistry<G, K, KIt> Registry;
    3.32 -		typedef K Key;
    3.33 -		typedef KIt KeyIt;
    3.34 -	
    3.35 -		friend class Registry;
    3.36 -		
    3.37 -		/** 
    3.38 -			Default constructor.
    3.39 -		*/	
    3.40 -		
    3.41 -		MapBase() : graph(0), registry(0) {}
    3.42 -
    3.43 -		/** 
    3.44 -			Simple constructor to register into a graph registry.
    3.45 -		*/
    3.46 -	
    3.47 -		MapBase(Graph& g, Registry& r) : graph(&g), registry(0) {
    3.48 -			r.attach(*this);
    3.49 -		}
    3.50 -
    3.51 -		/** 
    3.52 -			Copy constructor with registering into the map.
    3.53 -		*/	
    3.54 -	
    3.55 -		MapBase(const MapBase& copy) : registry(0), graph(copy.graph) {
    3.56 -			if (copy.registry) {
    3.57 -				copy.registry->attach(*this);
    3.58 -			}
    3.59 -		} 
    3.60 -	
    3.61 -		/** 
    3.62 -			Assign operator.
    3.63 -		*/	
    3.64 -
    3.65 -		const MapBase& operator=(const MapBase& copy) {
    3.66 -			if (registry) {
    3.67 -				registry->detach(*this);
    3.68 -			}
    3.69 -			graph = copy.graph;
    3.70 -			if (copy.registry) {
    3.71 -				copy.registry->attach(*this);
    3.72 -			}
    3.73 -		}
    3.74 -	
    3.75 -
    3.76 -		/** 
    3.77 -			Destructor.
    3.78 -		*/		
    3.79 -
    3.80 -		virtual ~MapBase() {
    3.81 -			if (registry) {
    3.82 -				registry->detach(*this);
    3.83 -			}
    3.84 -		}
    3.85 -	
    3.86 -	protected:
    3.87 -		
    3.88 -		Graph* graph;
    3.89 -		Registry* registry;
    3.90 -
    3.91 -		int registry_index;
    3.92 -	
    3.93 -		/**
    3.94 -			Helper function to implement constructors in the subclasses.
    3.95 -		*/
    3.96 -	
    3.97 -		virtual void init() {
    3.98 -			for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
    3.99 -				add(it);
   3.100 -			}
   3.101 -		}
   3.102 -	
   3.103 -		/**
   3.104 -			Helper function to implement the destructor in the subclasses.
   3.105 -		*/
   3.106 -	
   3.107 -		virtual void destroy() {
   3.108 -			for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
   3.109 -				erase(it);
   3.110 -			}
   3.111 -		}
   3.112 -	
   3.113 -		/** 
   3.114 -			The add member function should be overloaded in the subclasses.
   3.115 -			\e Add extends the map with the new node.
   3.116 -		*/
   3.117 -	
   3.118 -		virtual void add(const Key&) = 0;	
   3.119 -		/** 
   3.120 -			The erase member function should be overloaded in the subclasses.
   3.121 -			\e Erase removes the node from the map.
   3.122 -		*/
   3.123 -	
   3.124 -		virtual void erase(const Key&) = 0;
   3.125 -	
   3.126 -		/**
   3.127 -			Exception class to throw at unsupported operation.
   3.128 -		*/
   3.129 -	
   3.130 -		class NotSupportedOperationException {};
   3.131 -
   3.132 -	};
   3.133 -	
   3.134 -}
   3.135 -
   3.136 -#endif
     4.1 --- a/src/work/deba/map_registry.h	Wed May 12 14:07:00 2004 +0000
     4.2 +++ b/src/work/deba/map_registry.h	Thu May 13 08:20:39 2004 +0000
     4.3 @@ -5,91 +5,195 @@
     4.4  
     4.5  using namespace std;
     4.6  
     4.7 -
     4.8 -namespace hugo {
     4.9 -	template <typename G, typename K, typename KIt>
    4.10 -	class MapRegistry;
    4.11 -}
    4.12 -
    4.13 -#include "map_base.h"
    4.14 +/** 
    4.15 +    Registry class to register edge or node maps in the graph. The
    4.16 +    registry helps you to implement an observer pattern. If you add
    4.17 +    or erase an edge or node you must notify all the maps about the
    4.18 +    event.
    4.19 +*/
    4.20  
    4.21  namespace hugo {
    4.22  
    4.23 -	template <typename G, typename K, typename KIt>
    4.24 -	class MapRegistry {
    4.25 -	public:
    4.26 -		typedef G Graph;
    4.27 -		typedef K Key;
    4.28 -		typedef KIt KeyIt;
    4.29 +  template <typename G, typename K, typename KIt>
    4.30 +  class MapRegistry {
    4.31 +  public:
    4.32 +    typedef G Graph;
    4.33 +    typedef K Key;
    4.34 +    typedef KIt KeyIt;
    4.35  	
    4.36 -		typedef MapBase<Graph, Key, KIt> Map;
    4.37 -		friend class Base;
    4.38 +
    4.39 +
    4.40 +    class MapBase {
    4.41 +    public:
    4.42 +      typedef G Graph;
    4.43 +      typedef MapRegistry<G, K, KIt> Registry;
    4.44 +      typedef K Key;
    4.45 +      typedef KIt KeyIt;
    4.46  	
    4.47 -	protected:
    4.48 +      friend class Registry;
    4.49 +		
    4.50 +      /** 
    4.51 +	  Default constructor.
    4.52 +      */	
    4.53 +		
    4.54 +      MapBase() : graph(0), registry(0) {}
    4.55 +
    4.56 +      /** 
    4.57 +	  Simple constructor to register into a graph registry.
    4.58 +      */
    4.59  	
    4.60 -		typedef std::vector<Map*> Container; 
    4.61 -	  Container container;
    4.62 +      MapBase(Graph& g, Registry& r) : graph(&g), registry(0) {
    4.63 +	r.attach(*this);
    4.64 +      }
    4.65 +
    4.66 +      /** 
    4.67 +	  Copy constructor with registering into the map.
    4.68 +      */	
    4.69 +	
    4.70 +      MapBase(const MapBase& copy) : registry(0), graph(copy.graph) {
    4.71 +	if (copy.registry) {
    4.72 +	  copy.registry->attach(*this);
    4.73 +	}
    4.74 +      } 
    4.75 +	
    4.76 +      /** 
    4.77 +	  Assign operator.
    4.78 +      */	
    4.79 +
    4.80 +      const MapBase& operator=(const MapBase& copy) {
    4.81 +	if (registry) {
    4.82 +	  registry->detach(*this);
    4.83 +	}
    4.84 +	graph = copy.graph;
    4.85 +	if (copy.registry) {
    4.86 +	  copy.registry->attach(*this);
    4.87 +	}
    4.88 +      }
    4.89 +	
    4.90 +
    4.91 +      /** 
    4.92 +	  Destructor.
    4.93 +      */		
    4.94 +
    4.95 +      virtual ~MapBase() {
    4.96 +	if (registry) {
    4.97 +	  registry->detach(*this);
    4.98 +	}
    4.99 +      }
   4.100 +	
   4.101 +    protected:
   4.102 +		
   4.103 +      Graph* graph;
   4.104 +      Registry* registry;
   4.105 +
   4.106 +      int registry_index;
   4.107 +	
   4.108 +      /**
   4.109 +	 Helper function to implement constructors in the subclasses.
   4.110 +      */
   4.111 +	
   4.112 +      virtual void init() {
   4.113 +	for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
   4.114 +	  add(it);
   4.115 +	}
   4.116 +      }
   4.117 +	
   4.118 +      /**
   4.119 +	 Helper function to implement the destructor in the subclasses.
   4.120 +      */
   4.121 +	
   4.122 +      virtual void destroy() {
   4.123 +	for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
   4.124 +	  erase(it);
   4.125 +	}
   4.126 +      }
   4.127 +	
   4.128 +      /** 
   4.129 +	  The add member function should be overloaded in the subclasses.
   4.130 +	  \e Add extends the map with the new node.
   4.131 +      */
   4.132 +	
   4.133 +      virtual void add(const Key&) = 0;	
   4.134 +      /** 
   4.135 +	  The erase member function should be overloaded in the subclasses.
   4.136 +	  \e Erase removes the node from the map.
   4.137 +      */
   4.138 +	
   4.139 +      virtual void erase(const Key&) = 0;
   4.140 +	
   4.141 +      /**
   4.142 +	 Exception class to throw at unsupported operation.
   4.143 +      */
   4.144 +	
   4.145 +      class NotSupportedOperationException {};
   4.146 +
   4.147 +    };
   4.148 +	
   4.149 +  protected:
   4.150 +	
   4.151 +    typedef std::vector<MapBase*> Container; 
   4.152 +    Container container;
   4.153  
   4.154  		
   4.155 -	public:
   4.156 +    public:
   4.157  	
   4.158 -		MapRegistry() {}
   4.159 +    MapRegistry() {}
   4.160  	
   4.161 -		MapRegistry(const MapRegistry&) {}
   4.162 +    MapRegistry(const MapRegistry&) {}
   4.163  		
   4.164 -		MapRegistry& operator=(const MapRegistry&) {
   4.165 -			for (it = container.begin(); it != container.end(); ++it) {
   4.166 -				(*it)->destroy();
   4.167 -				(*it)->graph = 0;
   4.168 -				(*it)->registry = 0;
   4.169 -			}
   4.170 -		}
   4.171 +    MapRegistry& operator=(const MapRegistry&) {
   4.172 +      for (it = container.begin(); it != container.end(); ++it) {
   4.173 +	(*it)->destroy();
   4.174 +	(*it)->graph = 0;
   4.175 +	(*it)->registry = 0;
   4.176 +      }
   4.177 +    }
   4.178  				
   4.179 -		~MapRegistry() {
   4.180 -			typename Container::iterator it;
   4.181 -			for (it = container.begin(); it != container.end(); ++it) {
   4.182 -				(*it)->destroy();
   4.183 -				(*it)->registry = 0;
   4.184 -				(*it)->graph = 0;
   4.185 -			}
   4.186 -		}
   4.187 +    ~MapRegistry() {
   4.188 +      typename Container::iterator it;
   4.189 +      for (it = container.begin(); it != container.end(); ++it) {
   4.190 +	(*it)->destroy();
   4.191 +	(*it)->registry = 0;
   4.192 +	(*it)->graph = 0;
   4.193 +      }
   4.194 +    }
   4.195  	
   4.196  	
   4.197 -	public:
   4.198 +    public:
   4.199  	
   4.200 -		void attach(Map& map) {
   4.201 -			if (map.registry) {
   4.202 -				map.registry->detach(map);
   4.203 -			}
   4.204 -			container.push_back(&map);
   4.205 -			map.registry = this;
   4.206 -			map.registry_index = container.size()-1;
   4.207 -		} 
   4.208 +    void attach(MapBase& map) {
   4.209 +      if (map.registry) {
   4.210 +	map.registry->detach(map);
   4.211 +      }
   4.212 +      container.push_back(&map);
   4.213 +      map.registry = this;
   4.214 +      map.registry_index = container.size()-1;
   4.215 +    } 
   4.216  	
   4.217 -		void detach(Map& map) {
   4.218 -			container.back()->registry_index = map.registry_index; 
   4.219 -			container[map.registry_index] = container.back();
   4.220 -			container.pop_back();
   4.221 -			map.registry = 0;
   4.222 -			map.graph = 0;
   4.223 -		}
   4.224 +    void detach(MapBase& map) {
   4.225 +      container.back()->registry_index = map.registry_index; 
   4.226 +      container[map.registry_index] = container.back();
   4.227 +      container.pop_back();
   4.228 +      map.registry = 0;
   4.229 +      map.graph = 0;
   4.230 +    }
   4.231  	
   4.232  		
   4.233 -		virtual void add(Key& key) {
   4.234 -			typename Container::iterator it;
   4.235 -			for (it = container.begin(); it != container.end(); ++it) {
   4.236 -				(*it)->add(key);
   4.237 -			}
   4.238 -		}	
   4.239 +    virtual void add(Key& key) {
   4.240 +      typename Container::iterator it;
   4.241 +      for (it = container.begin(); it != container.end(); ++it) {
   4.242 +	(*it)->add(key);
   4.243 +      }
   4.244 +    }	
   4.245  		
   4.246 -		virtual void erase(Key& key) {
   4.247 -			typename Container::iterator it;
   4.248 -			for (it = container.begin(); it != container.end(); ++it) {
   4.249 -				(*it)->erase(key);
   4.250 -			}
   4.251 -		}
   4.252 +    virtual void erase(Key& key) {
   4.253 +      typename Container::iterator it;
   4.254 +      for (it = container.begin(); it != container.end(); ++it) {
   4.255 +	(*it)->erase(key);
   4.256 +      }
   4.257 +    }
   4.258  
   4.259 -	};
   4.260 +  };
   4.261  
   4.262  }
   4.263  
     5.1 --- a/src/work/deba/test_graph.h	Wed May 12 14:07:00 2004 +0000
     5.2 +++ b/src/work/deba/test_graph.h	Thu May 13 08:20:39 2004 +0000
     5.3 @@ -30,28 +30,26 @@
     5.4      class InEdgeIt;
     5.5      class SymEdgeIt;
     5.6      
     5.7 -//    template <typename T> class NodeMap;
     5.8 -//    template <typename T> class EdgeMap;
     5.9 +    //    template <typename T> class NodeMap;
    5.10 +    //    template <typename T> class EdgeMap;
    5.11    private:
    5.12 -//    template <typename T> friend class NodeMap;
    5.13 - //   template <typename T> friend class EdgeMap;
    5.14 +    //    template <typename T> friend class NodeMap;
    5.15 +    //   template <typename T> friend class EdgeMap;
    5.16   
    5.17    private:
    5.18  
    5.19   
    5.20 -	public:
    5.21 +  public:
    5.22  	
    5.23 -		typedef MapBase<ListGraph, Node, NodeIt> NodeMapBase;
    5.24 -		typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
    5.25 -		typedef VectorMapFactory<ListGraph, Node, NodeIt> NodeMapFactory;
    5.26 -		NodeMapRegistry node_maps;
    5.27 +    typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
    5.28 +    typedef VectorMapFactory<NodeMapRegistry> NodeMapFactory;
    5.29 +    NodeMapRegistry node_maps;
    5.30  
    5.31  
    5.32  
    5.33 -		typedef MapBase<ListGraph, Edge, EdgeIt> EdgeMapBase;
    5.34 -		typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
    5.35 -		typedef VectorMapFactory<ListGraph, Edge, EdgeIt> EdgeMapFactory;
    5.36 -		EdgeMapRegistry edge_maps;
    5.37 +    typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
    5.38 +    typedef VectorMapFactory<EdgeMapRegistry> EdgeMapFactory;
    5.39 +    EdgeMapRegistry edge_maps;
    5.40   
    5.41  
    5.42      int node_id;
    5.43 @@ -302,27 +300,27 @@
    5.44      /* adding nodes and edges */
    5.45  
    5.46      Node addNode() { 
    5.47 -			Node n = _add_node();
    5.48 -			node_maps.add(n);
    5.49 -			return n; 
    5.50 -		}
    5.51 +      Node n = _add_node();
    5.52 +      node_maps.add(n);
    5.53 +      return n; 
    5.54 +    }
    5.55      Edge addEdge(Node u, Node v) {
    5.56 -			Edge e = _add_edge(u.node, v.node);
    5.57 -			edge_maps.add(e);
    5.58 +      Edge e = _add_edge(u.node, v.node);
    5.59 +      edge_maps.add(e);
    5.60        return e; 
    5.61      }
    5.62  
    5.63      void erase(Node i) { 
    5.64 -			node_maps.erase(i);
    5.65 +      node_maps.erase(i);
    5.66        while (first<OutEdgeIt>(i).valid()) erase(first<OutEdgeIt>(i));
    5.67        while (first<InEdgeIt>(i).valid()) erase(first<InEdgeIt>(i));
    5.68        _delete_node(i.node); 
    5.69      }
    5.70    
    5.71      void erase(Edge e) { 
    5.72 -			edge_maps.erase(e);
    5.73 -			_delete_edge(e.edge); 
    5.74 -		}
    5.75 +      edge_maps.erase(e);
    5.76 +      _delete_edge(e.edge); 
    5.77 +    }
    5.78  
    5.79      void clear() { 
    5.80        while (first<NodeIt>().valid()) erase(first<NodeIt>());
    5.81 @@ -510,42 +508,42 @@
    5.82  
    5.83    };
    5.84  
    5.85 -//   template< typename T >
    5.86 -//   T ListGraph::first() const { 
    5.87 -//     std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>();" << std::endl; 
    5.88 -//     return T(); 
    5.89 -//   }
    5.90 +  //   template< typename T >
    5.91 +  //   T ListGraph::first() const { 
    5.92 +  //     std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>();" << std::endl; 
    5.93 +  //     return T(); 
    5.94 +  //   }
    5.95  
    5.96 -//   template<>
    5.97 -//   ListGraph::NodeIt ListGraph::first<ListGraph::NodeIt>() const { 
    5.98 -//     return firstNode(); 
    5.99 -//   }
   5.100 +  //   template<>
   5.101 +  //   ListGraph::NodeIt ListGraph::first<ListGraph::NodeIt>() const { 
   5.102 +  //     return firstNode(); 
   5.103 +  //   }
   5.104  
   5.105 -//   template<>
   5.106 -//   ListGraph::EdgeIt ListGraph::first<ListGraph::EdgeIt>() const { 
   5.107 -//     return firstEdge(); 
   5.108 -//   }
   5.109 +  //   template<>
   5.110 +  //   ListGraph::EdgeIt ListGraph::first<ListGraph::EdgeIt>() const { 
   5.111 +  //     return firstEdge(); 
   5.112 +  //   }
   5.113  
   5.114 -//   template< typename T >
   5.115 -//   T ListGraph::first(ListGraph::Node v) const {
   5.116 -//     std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>(ListGRaph::Node);" << std::endl; 
   5.117 -//     return T(); 
   5.118 -//   } 
   5.119 +  //   template< typename T >
   5.120 +  //   T ListGraph::first(ListGraph::Node v) const {
   5.121 +  //     std::cerr << "Invalid use of template<typemane T> T ListGraph::first<T>(ListGRaph::Node);" << std::endl; 
   5.122 +  //     return T(); 
   5.123 +  //   } 
   5.124  
   5.125 -//   template<>
   5.126 -//   ListGraph::OutEdgeIt ListGraph::first<ListGraph::OutEdgeIt>(const ListGraph::Node v) const { 
   5.127 -//     return firstOutEdge(v); 
   5.128 -//   }
   5.129 +  //   template<>
   5.130 +  //   ListGraph::OutEdgeIt ListGraph::first<ListGraph::OutEdgeIt>(const ListGraph::Node v) const { 
   5.131 +  //     return firstOutEdge(v); 
   5.132 +  //   }
   5.133  
   5.134 -//   template<>
   5.135 -//   ListGraph::InEdgeIt ListGraph::first<ListGraph::InEdgeIt>(const ListGraph::Node v) const { 
   5.136 -//     return firstInEdge(v); 
   5.137 -//   }
   5.138 +  //   template<>
   5.139 +  //   ListGraph::InEdgeIt ListGraph::first<ListGraph::InEdgeIt>(const ListGraph::Node v) const { 
   5.140 +  //     return firstInEdge(v); 
   5.141 +  //   }
   5.142  
   5.143 -//   template<>
   5.144 -//   ListGraph::SymEdgeIt ListGraph::first<ListGraph::SymEdgeIt>(const ListGraph::Node v) const { 
   5.145 -//     return firstSymEdge(v); 
   5.146 -//   }
   5.147 +  //   template<>
   5.148 +  //   ListGraph::SymEdgeIt ListGraph::first<ListGraph::SymEdgeIt>(const ListGraph::Node v) const { 
   5.149 +  //     return firstSymEdge(v); 
   5.150 +  //   }
   5.151  
   5.152  
   5.153  } //namespace hugo
     6.1 --- a/src/work/deba/vector_map_factory.h	Wed May 12 14:07:00 2004 +0000
     6.2 +++ b/src/work/deba/vector_map_factory.h	Thu May 13 08:20:39 2004 +0000
     6.3 @@ -3,73 +3,73 @@
     6.4  
     6.5  #include <vector>
     6.6  
     6.7 -#include "map_base.h"
     6.8 +#include "map_registry.h"
     6.9  
    6.10  namespace hugo {
    6.11  	
    6.12 -	template <typename G, typename K, typename KIt>
    6.13 -	class VectorMapFactory {
    6.14 +  template <typename MapRegistry>
    6.15 +  class VectorMapFactory {
    6.16 +  public:
    6.17 +		
    6.18 +    typedef typename MapRegistry::Graph Graph;
    6.19 +    typedef typename MapRegistry::Key Key;
    6.20 +    typedef typename MapRegistry::KeyIt KeyIt;
    6.21 +
    6.22 +    typedef typename MapRegistry::MapBase MapBase;
    6.23 +		
    6.24 +    template <typename V> 
    6.25 +      class Map : public MapBase {
    6.26 +      public:
    6.27 +      typedef V Value;
    6.28  	
    6.29 +      Map() {}
    6.30 +			
    6.31 +      Map(Graph& g, MapRegistry& r) : MapBase(g, r) {
    6.32 +	init();
    6.33 +      }
    6.34 +			
    6.35 +						
    6.36 +      virtual ~Map() {
    6.37 +	destroy();
    6.38 +      }
    6.39  	
    6.40 -	public:
    6.41 +	
    6.42 +      Value& operator[](const Key& key) {
    6.43 +	int id = graph->id(key);
    6.44 +	return container[id];
    6.45 +      } 
    6.46  		
    6.47 -		typedef G Graph;
    6.48 -		typedef K Key;
    6.49 -		typedef KIt KeyIt;
    6.50 +      const Value& operator[](const Key& key) const {
    6.51 +	int id = graph->id(key);
    6.52 +	return container[id];
    6.53 +      }
    6.54 +	
    6.55 +      const Value& get(const Key& key) const {
    6.56 +	int id = graph->id(key);
    6.57 +	return container[id];
    6.58 +      } 
    6.59  		
    6.60 -		template <typename V> 
    6.61 -		class Map : public MapBase<G, K, KIt> {
    6.62 -		public:
    6.63 -			typedef V Value;
    6.64 +      void set(const Key& key, const Value& val) {
    6.65 +	int id = graph->id(key);
    6.66 +	container[id] = val;
    6.67 +      }
    6.68 +		
    6.69 +      void add(const Key& key) {
    6.70 +	int id = graph->id(key);
    6.71 +	if (id >= container.size()) {
    6.72 +	  container.resize(id + 1);
    6.73 +	}
    6.74 +      }
    6.75 +		
    6.76 +      void erase(const Key& key) {}
    6.77  	
    6.78 -			Map() {}
    6.79 -			
    6.80 -			Map(Graph& g, MapRegistry<G, K, KIt>& r) 
    6.81 -				: MapBase<G, K, KIt>(g, r) {
    6.82 -				init();
    6.83 -			}
    6.84 -				
    6.85 -			virtual ~Map() {
    6.86 -				destroy();
    6.87 -			}
    6.88 -	
    6.89 -	
    6.90 -			Value& operator[](const K& key) {
    6.91 -				int id = graph->id(key);
    6.92 -				return container[id];
    6.93 -			} 
    6.94 +      private:
    6.95 +      typedef std::vector<Value> Container;
    6.96  		
    6.97 -			const Value& operator[](const K& key) const {
    6.98 -				int id = graph->id(key);
    6.99 -				return container[id];
   6.100 -			}
   6.101 -	
   6.102 -			const Value& get(const K& key) const {
   6.103 -				int id = graph->id(key);
   6.104 -				return container[id];
   6.105 -			} 
   6.106 +      Container container;
   6.107 +    };
   6.108  		
   6.109 -			void set(const K& key, const Value& val) {
   6.110 -				int id = graph->id(key);
   6.111 -				container[id] = val;
   6.112 -			}
   6.113 -		
   6.114 -			void add(const K& key) {
   6.115 -				int id = graph->id(key);
   6.116 -				if (id >= container.size()) {
   6.117 -					container.resize(id + 1);
   6.118 -				}
   6.119 -			}
   6.120 -		
   6.121 -			void erase(const K& key) {}
   6.122 -	
   6.123 -		private:
   6.124 -			typedef std::vector<Value> Container;
   6.125 -		
   6.126 -			Container container;
   6.127 -		};
   6.128 -		
   6.129 -	};
   6.130 +  };
   6.131  }
   6.132  
   6.133  #endif