Index: src/work/deba/array_map_factory.h
===================================================================
--- src/work/deba/array_map_factory.h	(revision 627)
+++ src/work/deba/array_map_factory.h	(revision 674)
@@ -4,5 +4,4 @@
 #include <memory>
 
-#include "map_base.h"
 
 #include <iostream>
@@ -11,112 +10,117 @@
 namespace hugo {
 	
-	template <typename G, typename K, typename KIt>
-	class ArrayMapFactory {
+  template <typename MapRegistry> class ArrayMapFactory {
+		
+  public:
+		
+    typedef typename MapRegistry::Graph Graph;
+    typedef typename MapRegistry::Key Key;
+    typedef typename MapRegistry::KeyIt KeyIt;
+
+    typedef typename MapRegistry::MapBase MapBase;
+		
+    template <typename V, typename A = std::allocator<V> > 
+      class Map : public MapBase {
+    
+	public:
+
+	typedef V Value;
+	typedef A Allocator;
+
+	
+	Map() : values(0), capacity(0) {}
+			
+	Map(Graph& g, MapRegistry& r) : MapBase(g, r) {
+	  int max_id = -1;
+	  for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
+	    int id = graph->id(it);
+	    if (id > max_id) {
+	      max_id = id;
+	    }			
+	  }
+	  if (max_id == -1) {
+	    capacity = 0;
+	    values = 0;
+	    return;
+	  }
+	  capacity = 1;
+	  while (capacity <= max_id) {
+	    capacity <<= 1;
+	  }
+	  values = allocator.allocate(capacity);
+	  for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
+	    int id = graph->id(it);
+	    allocator.construct(&(values[id]), Value());
+	  }								
+	}
+
+	Map(const Map& copy) : MapBase(*copy.graph, *copy.registry) {
+	  capacity = copy.capacity;
+	  values = allocator.allocate(capacity);
+	  for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
+	    int id = graph->id(it);
+	    allocator.construct(&(values[id]), copy.values[id]);
+	  }
+	}
+				
+	virtual ~Map() {
+	  destroy();
+	  allocator.deallocate(values, capacity);
+	}
 	
 	
-	public:
+	Value& operator[](const Key& key) {
+	  int id = graph->id(key);
+	  return values[id];
+	} 
 		
-		typedef G Graph;
-		typedef K Key;
-		typedef KIt KeyIt;
+	const Value& operator[](const Key& key) const {
+	  int id = graph->id(key);
+	  return values[id];
+	}
+	
+	const Value& get(const Key& key) const {
+	  int id = graph->id(key);
+	  return values[id];
+	} 
 		
-		template <typename V, typename A = allocator<V> > 
-		class Map : public MapBase<G, K, KIt> {
-		public:
-			typedef V Value;
-			typedef typename _Alloc_traits<V, A>::_Alloc_type _Alloc_type;
-
+	void set(const Key& key, const Value& val) {
+	  int id = graph->id(key);
+	  values[id] = val;
+	}
+		
+	void add(const Key& key) {
+	  int id = graph->id(key);
+	  if (id >= capacity) {
+	    int new_capacity = (capacity == 0 ? 1 : capacity);
+	    while (new_capacity <= id) {
+	      new_capacity <<= 1;
+	    }
+	    Value* new_values = allocator.allocate(new_capacity);;
+	    for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
+	      int jd = graph->id(it);
+	      if (id != jd) {
+		allocator.construct(&(new_values[jd]), values[jd]);
+		allocator.destroy(&(values[jd]));
+	      }
+	    }
+	    if (capacity != 0) allocator.deallocate(values, capacity);
+	    values = new_values;
+	    capacity = new_capacity;
+	  }
+	  allocator.construct(&(values[id]), Value());
+	}
+		
+	void erase(const Key& key) {
+	  int id = graph->id(key);
+	  allocator.destroy(&(values[id]));
+	}
 	
-			Map() : values(0), capacity(0) {}
-			
-			Map(Graph& g, MapRegistry<G, K, KIt>& r) 
-				: MapBase<G, K, KIt>(g, r) {
-				int max_id = -1;
-				for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
-					int id = graph->id(it);
-					if (id > max_id) {
-						max_id = id;
-					}				
-				}
-				if (max_id == -1) {
-					capacity = 0;
-					values = 0;
-					return;
-				}
-				int capacity = 1;
-				while (capacity <= max_id) {
-					capacity <<= 1;
-				}
-				Value* values = reinterpret_cast<Value*>(new char[capacity*sizeof(Value)]);
-				for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
-					int id = graph->id(it);
-					new(&(values[id])) Value();
-				}								
-				cerr << capacity << endl;	
-			}
-				
-			virtual ~Map() {
-				destroy();
-				delete[] reinterpret_cast<char*>(values);
-				values = 0;
-				capacity = 0;
-			}
-	
-	
-			Value& operator[](const K& key) {
-				int id = graph->id(key);
-				return values[id];
-			} 
-		
-			const Value& operator[](const K& key) const {
-				int id = graph->id(key);
-				return values[id];
-			}
-	
-			const Value& get(const K& key) const {
-				int id = graph->id(key);
-				return values[id];
-			} 
-		
-			void set(const K& key, const Value& val) {
-				int id = graph->id(key);
-				values[id] = val;
-			}
-		
-			void add(const K& key) {
-				cerr << capacity << endl;
-				int id = graph->id(key);
-				if (id >= capacity) {
-					int new_capacity = (capacity == 0 ? 1 : capacity);
-					while (new_capacity <= id) {
-						new_capacity <<= 1;
-					}
-					Value* new_values = reinterpret_cast<Value*>(new char[new_capacity*sizeof(Value)]);;
-					for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
-						int jd = graph->id(it);
-						if (id != jd) {
-							new(&(new_values[jd])) Value(values[jd]);
-						}
-					}
-					if (capacity != 0) delete[] reinterpret_cast<char *>(values);
-					values = new_values;
-					capacity = new_capacity;
-				}
-				cerr << id << ' ' << capacity << endl;
-				new(&(values[id])) Value();
-			}
-		
-			void erase(const K& key) {
-				int id = graph->id(key);
-				values[id].~Value();
-			}
-	
-		private:
-			int capacity;
-			Value* values;
-								
-		};
-		
-	};
+	private:
+	int capacity;
+	Value* values;
+	Allocator allocator;
+      };		
+  };
 }
 
Index: src/work/deba/main.cpp
===================================================================
--- src/work/deba/main.cpp	(revision 627)
+++ src/work/deba/main.cpp	(revision 674)
@@ -12,5 +12,5 @@
     ListGraph::Node node = g.addNode();
   }
-  ListGraph::NodeMapFactory::Map<int> map(g, g.node_maps);
+  ListGraph::NodeMap<int> map(g);
   for (int i = 0; i < 10; ++i) {
     ListGraph::Node node = g.addNode();
Index: src/work/deba/map_defines.h
===================================================================
--- src/work/deba/map_defines.h	(revision 674)
+++ src/work/deba/map_defines.h	(revision 674)
@@ -0,0 +1,47 @@
+#ifndef MAP_DEFINES_H
+#define MAP_DEFINES_H
+
+#define CREATE_EDGE_MAP_REGISTRY \
+typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
+EdgeMapRegistry edge_maps;
+
+#define CREATE_NODE_MAP_REGISTRY \
+typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
+NodeMapRegistry node_maps;
+
+#define CREATE_MAP_REGISTRIES \
+CREATE_NODE_MAP_REGISTRY \
+CREATE_EDGE_MAP_REGISTRY
+
+#define CREATE_NODE_MAP_FACTORY(TemplateFactory) \
+typedef TemplateFactory<NodeMapRegistry> NodeMapFactory;
+
+#define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \
+typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory;
+
+#define CREATE_MAP_FACTORIES(TemplateFactory) \
+CREATE_NODE_MAP_FACTORY(TemplateFactory) \
+CREATE_EDGE_MAP_FACTORY(TemplateFactory) 
+
+#define IMPORT_NODE_MAP(Factory) \
+template <typename V> \
+class NodeMap : public Factory::Map<V> { \
+public: \
+NodeMap() {} \
+NodeMap(Graph& g) : Factory::Map<V>(g, g.node_maps) {} \
+};
+
+#define IMPORT_EDGE_MAP(Factory) \
+template <typename V> \
+class EdgeMap : public Factory::Map<V> { \
+public: \
+EdgeMap() {} \
+EdgeMap(Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \
+};
+
+#define CREATE_MAPS(TemplateFactory) \
+CREATE_MAP_FACTORIES(TemplateFactory) \
+IMPORT_NODE_MAP(NodeMapFactory) \
+IMPORT_EDGE_MAP(EdgeMapFactory)
+
+#endif
Index: src/work/deba/test_graph.h
===================================================================
--- src/work/deba/test_graph.h	(revision 627)
+++ src/work/deba/test_graph.h	(revision 674)
@@ -8,5 +8,8 @@
 #include "invalid.h"
 
-#include "vector_map_factory.h"
+#include "map_registry.h"
+#include "array_map_factory.h"
+
+#include "map_defines.h"
 
 namespace hugo {
@@ -31,25 +34,10 @@
     class SymEdgeIt;
     
-    //    template <typename T> class NodeMap;
-    //    template <typename T> class EdgeMap;
+    typedef ListGraph Graph;
+ 
+    CREATE_MAP_REGISTRIES
+    CREATE_MAPS(ArrayMapFactory)
+
   private:
-    //    template <typename T> friend class NodeMap;
-    //   template <typename T> friend class EdgeMap;
- 
-  private:
-
- 
-  public:
-	
-    typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
-    typedef VectorMapFactory<NodeMapRegistry> NodeMapFactory;
-    NodeMapRegistry node_maps;
-
-
-
-    typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
-    typedef VectorMapFactory<EdgeMapRegistry> EdgeMapFactory;
-    EdgeMapRegistry edge_maps;
- 
 
     int node_id;
