src/work/deba/vector_map_factory.h
changeset 627 6cc21a9c9fda
parent 595 e10b5e9419ef
child 698 625de6f1e766
     1.1 --- a/src/work/deba/vector_map_factory.h	Wed May 12 14:07:00 2004 +0000
     1.2 +++ b/src/work/deba/vector_map_factory.h	Thu May 13 08:20:39 2004 +0000
     1.3 @@ -3,73 +3,73 @@
     1.4  
     1.5  #include <vector>
     1.6  
     1.7 -#include "map_base.h"
     1.8 +#include "map_registry.h"
     1.9  
    1.10  namespace hugo {
    1.11  	
    1.12 -	template <typename G, typename K, typename KIt>
    1.13 -	class VectorMapFactory {
    1.14 +  template <typename MapRegistry>
    1.15 +  class VectorMapFactory {
    1.16 +  public:
    1.17 +		
    1.18 +    typedef typename MapRegistry::Graph Graph;
    1.19 +    typedef typename MapRegistry::Key Key;
    1.20 +    typedef typename MapRegistry::KeyIt KeyIt;
    1.21 +
    1.22 +    typedef typename MapRegistry::MapBase MapBase;
    1.23 +		
    1.24 +    template <typename V> 
    1.25 +      class Map : public MapBase {
    1.26 +      public:
    1.27 +      typedef V Value;
    1.28  	
    1.29 +      Map() {}
    1.30 +			
    1.31 +      Map(Graph& g, MapRegistry& r) : MapBase(g, r) {
    1.32 +	init();
    1.33 +      }
    1.34 +			
    1.35 +						
    1.36 +      virtual ~Map() {
    1.37 +	destroy();
    1.38 +      }
    1.39  	
    1.40 -	public:
    1.41 +	
    1.42 +      Value& operator[](const Key& key) {
    1.43 +	int id = graph->id(key);
    1.44 +	return container[id];
    1.45 +      } 
    1.46  		
    1.47 -		typedef G Graph;
    1.48 -		typedef K Key;
    1.49 -		typedef KIt KeyIt;
    1.50 +      const Value& operator[](const Key& key) const {
    1.51 +	int id = graph->id(key);
    1.52 +	return container[id];
    1.53 +      }
    1.54 +	
    1.55 +      const Value& get(const Key& key) const {
    1.56 +	int id = graph->id(key);
    1.57 +	return container[id];
    1.58 +      } 
    1.59  		
    1.60 -		template <typename V> 
    1.61 -		class Map : public MapBase<G, K, KIt> {
    1.62 -		public:
    1.63 -			typedef V Value;
    1.64 +      void set(const Key& key, const Value& val) {
    1.65 +	int id = graph->id(key);
    1.66 +	container[id] = val;
    1.67 +      }
    1.68 +		
    1.69 +      void add(const Key& key) {
    1.70 +	int id = graph->id(key);
    1.71 +	if (id >= container.size()) {
    1.72 +	  container.resize(id + 1);
    1.73 +	}
    1.74 +      }
    1.75 +		
    1.76 +      void erase(const Key& key) {}
    1.77  	
    1.78 -			Map() {}
    1.79 -			
    1.80 -			Map(Graph& g, MapRegistry<G, K, KIt>& r) 
    1.81 -				: MapBase<G, K, KIt>(g, r) {
    1.82 -				init();
    1.83 -			}
    1.84 -				
    1.85 -			virtual ~Map() {
    1.86 -				destroy();
    1.87 -			}
    1.88 -	
    1.89 -	
    1.90 -			Value& operator[](const K& key) {
    1.91 -				int id = graph->id(key);
    1.92 -				return container[id];
    1.93 -			} 
    1.94 +      private:
    1.95 +      typedef std::vector<Value> Container;
    1.96  		
    1.97 -			const Value& operator[](const K& key) const {
    1.98 -				int id = graph->id(key);
    1.99 -				return container[id];
   1.100 -			}
   1.101 -	
   1.102 -			const Value& get(const K& key) const {
   1.103 -				int id = graph->id(key);
   1.104 -				return container[id];
   1.105 -			} 
   1.106 +      Container container;
   1.107 +    };
   1.108  		
   1.109 -			void set(const K& key, const Value& val) {
   1.110 -				int id = graph->id(key);
   1.111 -				container[id] = val;
   1.112 -			}
   1.113 -		
   1.114 -			void add(const K& key) {
   1.115 -				int id = graph->id(key);
   1.116 -				if (id >= container.size()) {
   1.117 -					container.resize(id + 1);
   1.118 -				}
   1.119 -			}
   1.120 -		
   1.121 -			void erase(const K& key) {}
   1.122 -	
   1.123 -		private:
   1.124 -			typedef std::vector<Value> Container;
   1.125 -		
   1.126 -			Container container;
   1.127 -		};
   1.128 -		
   1.129 -	};
   1.130 +  };
   1.131  }
   1.132  
   1.133  #endif