src/work/deba/pac_map_factory.h
changeset 595 e10b5e9419ef
child 921 818510fa3d99
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/deba/pac_map_factory.h	Mon May 10 13:49:35 2004 +0000
     1.3 @@ -0,0 +1,73 @@
     1.4 +#ifndef PAC_MAP_FACTORY_H
     1.5 +#define PAC_MAP_FACTORY_H
     1.6 +
     1.7 +#include "map_base.h"
     1.8 +
     1.9 +/**
    1.10 +	Converter class to use the standard template
    1.11 +	libary's pair associative containers as a graph map.
    1.12 +*/
    1.13 +
    1.14 +namespace hugo {
    1.15 +	
    1.16 +	template <typename G, typename K, typename KIt, template <typename, typename> class PAC>
    1.17 +	class PacMapFactory {
    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> 
    1.27 +		class Map : public MapBase<G, K, KIt> {
    1.28 +		public:
    1.29 +			typedef V Value;
    1.30 +	
    1.31 +			Map() {}
    1.32 +			
    1.33 +			Map(Graph& g, MapRegistry<G, K, KIt>& r) 
    1.34 +				: MapBase<G, K, KIt>(g, r) {
    1.35 +				init();
    1.36 +			}
    1.37 +				
    1.38 +			virtual ~Map() {
    1.39 +				destroy();
    1.40 +			}
    1.41 +	
    1.42 +	
    1.43 +			V& operator[](const K& key) {
    1.44 +				return container.find(key)->second;
    1.45 +			} 
    1.46 +		
    1.47 +			const V& operator[](const K& key) const {
    1.48 +				return container.find(key)->second;
    1.49 +			}
    1.50 +	
    1.51 +			const V& get(const K& key) const {
    1.52 +				return container.find(key)->second;
    1.53 +			} 
    1.54 +		
    1.55 +			void set(const K& key, const V& value) {
    1.56 +				container.find(key)->second = value;
    1.57 +			}
    1.58 +		
    1.59 +			void add(const K& key) {
    1.60 +				container.insert(key);
    1.61 +			}
    1.62 +		
    1.63 +			void erase(const K& key) {
    1.64 +				container.erase(key);
    1.65 +			}
    1.66 +	
    1.67 +		private:
    1.68 +			typedef PAC<K, V> Container;
    1.69 +		
    1.70 +			Container container;
    1.71 +		};
    1.72 +		
    1.73 +	};
    1.74 +}
    1.75 +
    1.76 +#endif
    1.77 \ No newline at end of file