lemon/maps.h
changeset 1554 572bc7d0d3e2
parent 1537 0d9f1a71be27
child 1555 48769ac7ec32
equal deleted inserted replaced
5:6aee5fa47ee5 6:5ede8eb7e3aa
   219     const Value& operator[](const Key& t) const {
   219     const Value& operator[](const Key& t) const {
   220       return t;
   220       return t;
   221     }
   221     }
   222   };
   222   };
   223 
   223 
   224   ///Convert the \c Value of a maps to another type.
   224   ///Convert the \c Value of a map to another type.
   225 
   225 
   226   ///This \ref concept::ReadMap "read only map"
   226   ///This \ref concept::ReadMap "read only map"
   227   ///converts the \c Value of a maps to type \c T.
   227   ///converts the \c Value of a maps to type \c T.
   228   ///Its \c Value is inherited from \c M.
   228   ///Its \c Key is inherited from \c M.
   229   ///
       
   230   ///\bug wrong documentation
       
   231   template<class M, class T> 
   229   template<class M, class T> 
   232   class ConvertMap {
   230   class ConvertMap {
   233     typename SmartConstReference<M>::Type m;
   231     typename SmartConstReference<M>::Type m;
   234   public:
   232   public:
   235 
   233 
   302   inline AddMap<M1,M2> addMap(const M1 &m1,const M2 &m2) 
   300   inline AddMap<M1,M2> addMap(const M1 &m1,const M2 &m2) 
   303   {
   301   {
   304     return AddMap<M1,M2>(m1,m2);
   302     return AddMap<M1,M2>(m1,m2);
   305   }
   303   }
   306 
   304 
   307   ///Shift a maps with a constant.
   305   ///Shift a map with a constant.
   308 
   306 
   309   ///This \ref concept::ReadMap "read only map" returns the sum of the
   307   ///This \ref concept::ReadMap "read only map" returns the sum of the
   310   ///given map and a constant value.
   308   ///given map and a constant value.
   311   ///Its \c Key and \c Value is inherited from \c M.
   309   ///Its \c Key and \c Value is inherited from \c M.
   312   ///
   310   ///
   313   ///Actually,
   311   ///Actually,
   314   ///\code
   312   ///\code
   315   ///  ShiftMap<X> sh(x,v);
   313   ///  ShiftMap<X> sh(x,v);
   316   ///\endcode
   314   ///\endcode
   317   ///it is equivalent with
   315   ///is equivalent with
   318   ///\code
   316   ///\code
   319   ///  ConstMap<X::Key, X::Value> c_tmp(v);
   317   ///  ConstMap<X::Key, X::Value> c_tmp(v);
   320   ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
   318   ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
   321   ///\endcode
   319   ///\endcode
   322   template<class M> 
   320   template<class M> 
   353   }
   351   }
   354 
   352 
   355   ///Difference of two maps
   353   ///Difference of two maps
   356 
   354 
   357   ///This \ref concept::ReadMap "read only map" returns the difference
   355   ///This \ref concept::ReadMap "read only map" returns the difference
   358   ///of the values returned by the two
   356   ///of the values of the two
   359   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   357   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   360   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   358   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   361 
   359 
   362   template<class M1,class M2> 
   360   template<class M1,class M2> 
   363   class SubMap
   361   class SubMap
   389   }
   387   }
   390 
   388 
   391   ///Product of two maps
   389   ///Product of two maps
   392 
   390 
   393   ///This \ref concept::ReadMap "read only map" returns the product of the
   391   ///This \ref concept::ReadMap "read only map" returns the product of the
   394   ///values returned by the two
   392   ///values of the two
   395   ///given
   393   ///given
   396   ///maps. Its \c Key and \c Value will be inherited from \c M1.
   394   ///maps. Its \c Key and \c Value will be inherited from \c M1.
   397   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   395   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   398 
   396 
   399   template<class M1,class M2> 
   397   template<class M1,class M2> 
   422   inline MulMap<M1,M2> mulMap(const M1 &m1,const M2 &m2) 
   420   inline MulMap<M1,M2> mulMap(const M1 &m1,const M2 &m2) 
   423   {
   421   {
   424     return MulMap<M1,M2>(m1,m2);
   422     return MulMap<M1,M2>(m1,m2);
   425   }
   423   }
   426  
   424  
   427   ///Scale a maps with a constant.
   425   ///Scales a maps with a constant.
   428 
   426 
   429   ///This \ref concept::ReadMap "read only map" returns the value of the
   427   ///This \ref concept::ReadMap "read only map" returns the value of the
   430   ///given map multipied with a constant value.
   428   ///given map multiplied with a constant value.
   431   ///Its \c Key and \c Value is inherited from \c M.
   429   ///Its \c Key and \c Value is inherited from \c M.
   432   ///
   430   ///
   433   ///Actually,
   431   ///Actually,
   434   ///\code
   432   ///\code
   435   ///  ScaleMap<X> sc(x,v);
   433   ///  ScaleMap<X> sc(x,v);
   436   ///\endcode
   434   ///\endcode
   437   ///it is equivalent with
   435   ///is equivalent with
   438   ///\code
   436   ///\code
   439   ///  ConstMap<X::Key, X::Value> c_tmp(v);
   437   ///  ConstMap<X::Key, X::Value> c_tmp(v);
   440   ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
   438   ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
   441   ///\endcode
   439   ///\endcode
   442   template<class M> 
   440   template<class M> 
   473   }
   471   }
   474 
   472 
   475   ///Quotient of two maps
   473   ///Quotient of two maps
   476 
   474 
   477   ///This \ref concept::ReadMap "read only map" returns the quotient of the
   475   ///This \ref concept::ReadMap "read only map" returns the quotient of the
   478   ///values returned by the two
   476   ///values of the two
   479   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   477   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   480   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   478   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   481 
   479 
   482   template<class M1,class M2> 
   480   template<class M1,class M2> 
   483   class DivMap
   481   class DivMap
   550   inline ComposeMap<M1,M2> composeMap(const M1 &m1,const M2 &m2) 
   548   inline ComposeMap<M1,M2> composeMap(const M1 &m1,const M2 &m2) 
   551   {
   549   {
   552     return ComposeMap<M1,M2>(m1,m2);
   550     return ComposeMap<M1,M2>(m1,m2);
   553   }
   551   }
   554   
   552   
   555   ///Combine of two maps using an STL (binary) functor.
   553   ///Combines of two maps using an STL (binary) functor.
   556 
   554 
   557   ///Combine of two maps using an STL (binary) functor.
   555   ///Combines of two maps using an STL (binary) functor.
   558   ///
   556   ///
   559   ///
   557   ///
   560   ///This \ref concept::ReadMap "read only map" takes to maps and a
   558   ///This \ref concept::ReadMap "read only map" takes two maps and a
   561   ///binary functor and returns the composition of
   559   ///binary functor and returns the composition of
   562   ///two
   560   ///the two
   563   ///given maps unsing the functor. 
   561   ///given maps unsing the functor. 
   564   ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
   562   ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
   565   ///and \c f is of \c F,
   563   ///and \c f is of \c F,
   566   ///then for
   564   ///then for
   567   ///\code
   565   ///\code
   787   {
   785   {
   788     return MapFunctor<M>(m);
   786     return MapFunctor<M>(m);
   789   }
   787   }
   790 
   788 
   791 
   789 
   792   ///Apply all map setting operations to two maps
   790   ///Applies all map setting operations to two maps
   793 
   791 
   794   ///This map has two \ref concept::WriteMap "writable map"
   792   ///This map has two \ref concept::WriteMap "writable map"
   795   ///parameters and each write request will be passed to both of them.
   793   ///parameters and each write request will be passed to both of them.
   796   ///If \c M1 is also \ref concept::ReadMap "readable",
   794   ///If \c M1 is also \ref concept::ReadMap "readable",
   797   ///then the read operations will return the
   795   ///then the read operations will return the