src/lemon/xy.h
changeset 1352 bdbb9144a49e
parent 1317 83f80464f111
child 1359 1581f961cfaa
equal deleted inserted replaced
12:f62475a73612 13:e21270cd957c
   337     typedef typename M::Value::Value Value;
   337     typedef typename M::Value::Value Value;
   338     typedef typename M::Key Key;
   338     typedef typename M::Key Key;
   339     ///\e
   339     ///\e
   340     XMap(M &map) : _map(map) {}
   340     XMap(M &map) : _map(map) {}
   341     Value operator[](Key k) const {return _map[k].x;}
   341     Value operator[](Key k) const {return _map[k].x;}
   342     Value set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
   342     void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
   343   };
   343   };
   344     
   344     
   345   ///Returns an \ref XMap class
   345   ///Returns an \ref XMap class
   346 
   346 
   347   ///This function just returns an \ref XMap class.
   347   ///This function just returns an \ref XMap class.
   394     typedef typename M::Value::Value Value;
   394     typedef typename M::Value::Value Value;
   395     typedef typename M::Key Key;
   395     typedef typename M::Key Key;
   396     ///\e
   396     ///\e
   397     YMap(M &map) : _map(map) {}
   397     YMap(M &map) : _map(map) {}
   398     Value operator[](Key k) const {return _map[k].y;}
   398     Value operator[](Key k) const {return _map[k].y;}
   399     Value set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
   399     void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
   400   };
   400   };
   401 
   401 
   402   ///Returns an \ref YMap class
   402   ///Returns an \ref YMap class
   403 
   403 
   404   ///This function just returns an \ref YMap class.
   404   ///This function just returns an \ref YMap class.
   438   {
   438   {
   439     return ConstYMap<M>(m);
   439     return ConstYMap<M>(m);
   440   }
   440   }
   441 
   441 
   442 
   442 
       
   443   ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map
       
   444 
       
   445   ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map
       
   446   ///\ingroup maps
       
   447   ///
       
   448   template<class M>
       
   449   class NormSquareMap 
       
   450   {
       
   451     const M &_map;
       
   452   public:
       
   453     typedef typename M::Value::Value Value;
       
   454     typedef typename M::Key Key;
       
   455     ///\e
       
   456     NormSquareMap(const M &map) : _map(map) {}
       
   457     Value operator[](Key k) const {return _map[k].normSquare();}
       
   458   };
       
   459     
       
   460   ///Returns a \ref NormSquareMap class
       
   461 
       
   462   ///This function just returns an \ref NormSquareMap class.
       
   463   ///
       
   464   ///\ingroup maps
       
   465   ///\relates NormSquareMap
       
   466   template<class M> 
       
   467   inline NormSquareMap<M> normSquareMap(const M &m) 
       
   468   {
       
   469     return NormSquareMap<M>(m);
       
   470   }
       
   471 
   443   /// @}
   472   /// @}
   444 
   473 
   445 
   474 
   446 } //namespace lemon
   475 } //namespace lemon
   447 
   476