lemon/maps.h
changeset 1545 e8378402f97e
parent 1536 308150155bb5
child 1547 dd57a540ff5f
equal deleted inserted replaced
4:5c386d44c23a 5:6aee5fa47ee5
   749 
   749 
   750   ///This class Converts a map to an STL style (unary) functor.
   750   ///This class Converts a map to an STL style (unary) functor.
   751   ///that is it provides an <tt>operator()</tt> to read its values.
   751   ///that is it provides an <tt>operator()</tt> to read its values.
   752   ///
   752   ///
   753   ///For the sake of convenience it also works as
   753   ///For the sake of convenience it also works as
   754   ///a ususal \ref concept::ReadMap "readable map", i.e
   754   ///a ususal \ref concept::ReadMap "readable map",
   755   ///<tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
   755   ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
   756 
   756 
   757   template<class M> 
   757   template<class M> 
   758   class MapFunctor
   758   class MapFunctor
   759   {
   759   {
   760     typename SmartConstReference<M>::Type m;
   760     typename SmartConstReference<M>::Type m;
   769     typedef typename M::Key Key;
   769     typedef typename M::Key Key;
   770     ///\e
   770     ///\e
   771     typedef typename M::Value Value;
   771     typedef typename M::Value Value;
   772 
   772 
   773     ///Constructor
   773     ///Constructor
   774 
       
   775     ///\e
       
   776     ///
       
   777     MapFunctor(const M &_m) : m(_m) {};
   774     MapFunctor(const M &_m) : m(_m) {};
   778     ///Returns a value of the map
   775     ///Returns a value of the map
   779     
       
   780     ///\e
       
   781     ///
       
   782     Value operator()(Key k) const {return m[k];}
   776     Value operator()(Key k) const {return m[k];}
   783     ///\e
   777     ///\e
   784     ///
       
   785     Value operator[](Key k) const {return m[k];}
   778     Value operator[](Key k) const {return m[k];}
   786   };
   779   };
   787   
   780   
   788   ///Returns a \ref MapFunctor class
   781   ///Returns a \ref MapFunctor class
   789 
   782 
   819     typedef typename M1::Key Key;
   812     typedef typename M1::Key Key;
   820     ///\e
   813     ///\e
   821     typedef typename M1::Value Value;
   814     typedef typename M1::Value Value;
   822 
   815 
   823     ///Constructor
   816     ///Constructor
   824 
       
   825     ///\e
       
   826     ///
       
   827     ForkMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   817     ForkMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   828     Value operator[](Key k) const {return m1[k];}
   818     Value operator[](Key k) const {return m1[k];}
   829     void set(Key k,const Value &v) {m1.set(k,v); m2.set(k,v);}
   819     void set(Key k,const Value &v) {m1.set(k,v); m2.set(k,v);}
   830   };
   820   };
   831   
   821   
   865     typedef typename M::Key Key;
   855     typedef typename M::Key Key;
   866     ///\e
   856     ///\e
   867     typedef bool Value;
   857     typedef bool Value;
   868 
   858 
   869     ///Constructor
   859     ///Constructor
   870 
       
   871     ///\e
       
   872     ///
       
   873     NotMap(const M &_m) : m(_m) {};
   860     NotMap(const M &_m) : m(_m) {};
   874     Value operator[](Key k) const {return !m[k];}
   861     Value operator[](Key k) const {return !m[k];}
   875   };
   862   };
   876   
   863   
   877   ///Returns a \ref NotMap class
   864   ///Returns a \ref NotMap class