diff -r e41c2907fb49 -r 3c176c65d33b src/lemon/maps.h --- a/src/lemon/maps.h Thu Feb 24 17:48:25 2005 +0000 +++ b/src/lemon/maps.h Fri Feb 25 14:50:22 2005 +0000 @@ -186,6 +186,49 @@ }; }; + ///Convert the \c Value of a maps to another type. + + ///This \ref concept::ReadMap "read only map" + ///converts the \c Value of a maps to type \c T. + ///Its \c Value is inherited from \c M. + /// + ///Actually, + ///\code + /// ConvertMap sh(x,v); + ///\endcode + ///it is equivalent with + ///\code + /// ConstMap c_tmp(v); + /// AddMap > sh(x,v); + ///\endcode + ///\bug wrong documentation + template + class ConvertMap + { + const M &m; + public: + typedef typename M::Key Key; + typedef T Value; + + ///Constructor + + ///Constructor + ///\param _m is the undelying map + ///\param _v is the convert value + ConvertMap(const M &_m) : m(_m) {}; + Value operator[](Key k) const {return m[k];} + }; + + ///Returns an \ref ConvertMap class + + ///This function just returns an \ref ConvertMap class. + ///\relates ConvertMap + ///\todo The order of the template parameters are changed. + template + inline ConvertMap convertMap(const M &m) + { + return ConvertMap(m); + } ///Sum of two maps