1.1 --- a/src/lemon/maps.h Thu Feb 24 17:48:25 2005 +0000
1.2 +++ b/src/lemon/maps.h Fri Feb 25 14:50:22 2005 +0000
1.3 @@ -186,6 +186,49 @@
1.4 };
1.5 };
1.6
1.7 + ///Convert the \c Value of a maps to another type.
1.8 +
1.9 + ///This \ref concept::ReadMap "read only map"
1.10 + ///converts the \c Value of a maps to type \c T.
1.11 + ///Its \c Value is inherited from \c M.
1.12 + ///
1.13 + ///Actually,
1.14 + ///\code
1.15 + /// ConvertMap<X> sh(x,v);
1.16 + ///\endcode
1.17 + ///it is equivalent with
1.18 + ///\code
1.19 + /// ConstMap<X::Key, X::Value> c_tmp(v);
1.20 + /// AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
1.21 + ///\endcode
1.22 + ///\bug wrong documentation
1.23 + template<class M, class T>
1.24 + class ConvertMap
1.25 + {
1.26 + const M &m;
1.27 + public:
1.28 + typedef typename M::Key Key;
1.29 + typedef T Value;
1.30 +
1.31 + ///Constructor
1.32 +
1.33 + ///Constructor
1.34 + ///\param _m is the undelying map
1.35 + ///\param _v is the convert value
1.36 + ConvertMap(const M &_m) : m(_m) {};
1.37 + Value operator[](Key k) const {return m[k];}
1.38 + };
1.39 +
1.40 + ///Returns an \ref ConvertMap class
1.41 +
1.42 + ///This function just returns an \ref ConvertMap class.
1.43 + ///\relates ConvertMap
1.44 + ///\todo The order of the template parameters are changed.
1.45 + template<class T, class M>
1.46 + inline ConvertMap<M,T> convertMap(const M &m)
1.47 + {
1.48 + return ConvertMap<M,T>(m);
1.49 + }
1.50
1.51 ///Sum of two maps
1.52