COIN-OR::LEMON - Graph Library

Changeset 1178:3c176c65d33b in lemon-0.x for src/lemon/maps.h


Ignore:
Timestamp:
02/25/05 15:50:22 (19 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1584
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/maps.h

    r1172 r1178  
    187187  };
    188188
     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  }
    189232
    190233  ///Sum of two maps
Note: See TracChangeset for help on using the changeset viewer.