src/lemon/maps.h
changeset 1184 aad134c6c9c5
parent 1172 37338ae42a2b
child 1219 ce885274b754
equal deleted inserted replaced
9:5845d41ceffc 10:a5a96e8331c5
   184     struct rebind {
   184     struct rebind {
   185       typedef StdMap<Key,T1,Compare> other;
   185       typedef StdMap<Key,T1,Compare> other;
   186     };
   186     };
   187   };
   187   };
   188 
   188 
       
   189   ///Convert the \c Value of a maps to another type.
       
   190 
       
   191   ///This \ref concept::ReadMap "read only map"
       
   192   ///converts the \c Value of a maps to type \c T.
       
   193   ///Its \c Value is inherited from \c M.
       
   194   ///
       
   195   ///Actually,
       
   196   ///\code
       
   197   ///  ConvertMap<X> sh(x,v);
       
   198   ///\endcode
       
   199   ///it is equivalent with
       
   200   ///\code
       
   201   ///  ConstMap<X::Key, X::Value> c_tmp(v);
       
   202   ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
       
   203   ///\endcode
       
   204   ///\bug wrong documentation
       
   205   template<class M, class T> 
       
   206   class ConvertMap
       
   207   {
       
   208     const M &m;
       
   209   public:
       
   210     typedef typename M::Key Key;
       
   211     typedef T Value;
       
   212 
       
   213     ///Constructor
       
   214 
       
   215     ///Constructor
       
   216     ///\param _m is the undelying map
       
   217     ///\param _v is the convert value
       
   218     ConvertMap(const M &_m) : m(_m) {};
       
   219     Value operator[](Key k) const {return m[k];}
       
   220   };
       
   221   
       
   222   ///Returns an \ref ConvertMap class
       
   223 
       
   224   ///This function just returns an \ref ConvertMap class.
       
   225   ///\relates ConvertMap
       
   226   ///\todo The order of the template parameters are changed.
       
   227   template<class T, class M>
       
   228   inline ConvertMap<M,T> convertMap(const M &m) 
       
   229   {
       
   230     return ConvertMap<M,T>(m);
       
   231   }
   189 
   232 
   190   ///Sum of two maps
   233   ///Sum of two maps
   191 
   234 
   192   ///This \ref concept::ReadMap "read only map" returns the sum of the two
   235   ///This \ref concept::ReadMap "read only map" returns the sum of the two
   193   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   236   ///given maps. Its \c Key and \c Value will be inherited from \c M1.