lemon/maps.h
changeset 2252 133028e83940
parent 2093 ff241247e157
child 2258 741995f3dbc4
equal deleted inserted replaced
24:737b2c26fcc1 25:6d5e9d388843
   285   template<typename T, typename M>
   285   template<typename T, typename M>
   286   inline ConvertMap<M, T> convertMap(const M &m) {
   286   inline ConvertMap<M, T> convertMap(const M &m) {
   287     return ConvertMap<M, T>(m);
   287     return ConvertMap<M, T>(m);
   288   }
   288   }
   289 
   289 
       
   290   ///Simple wrapping of the map
       
   291 
       
   292   ///This \ref concept::ReadMap "read only map" returns the simple
       
   293   ///wrapping of the given map. Sometimes the reference maps cannot be
       
   294   ///combined with simple read maps. This map adaptor wraps the given
       
   295   ///map to simple read map.
       
   296   template<typename M> 
       
   297   class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
       
   298     const M& m;
       
   299 
       
   300   public:
       
   301     typedef MapBase<typename M::Key, typename M::Value> Parent;
       
   302     typedef typename Parent::Key Key;
       
   303     typedef typename Parent::Value Value;
       
   304 
       
   305     ///Constructor
       
   306     SimpleMap(const M &_m) : m(_m) {};
       
   307     Value operator[](Key k) const {return m[k];}
       
   308   };
       
   309 
       
   310   ///Simple writeable wrapping of the map
       
   311 
       
   312   ///This \ref concept::ReadMap "read only map" returns the simple
       
   313   ///wrapping of the given map. Sometimes the reference maps cannot be
       
   314   ///combined with simple read-write maps. This map adaptor wraps the
       
   315   ///given map to simple read-write map.
       
   316   template<typename M> 
       
   317   class SimpleWriteMap : public MapBase<typename M::Key, typename M::Value> {
       
   318     M& m;
       
   319 
       
   320   public:
       
   321     typedef MapBase<typename M::Key, typename M::Value> Parent;
       
   322     typedef typename Parent::Key Key;
       
   323     typedef typename Parent::Value Value;
       
   324 
       
   325     ///Constructor
       
   326     SimpleWriteMap(M &_m) : m(_m) {};
       
   327     Value operator[](Key k) const {return m[k];}
       
   328     void set(Key k, const Value& c) { m.set(k, c); }
       
   329   };
       
   330 
   290   ///Sum of two maps
   331   ///Sum of two maps
   291 
   332 
   292   ///This \ref concept::ReadMap "read only map" returns the sum of the two
   333   ///This \ref concept::ReadMap "read only map" returns the sum of the two
   293   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   334   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   294   ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
   335   ///The \c Key and \c Value of M2 must be convertible to those of \c M1.