src/lemon/xy.h
changeset 1335 13a863ce81d9
parent 1257 7101e2c3a881
child 1352 bdbb9144a49e
equal deleted inserted replaced
11:e4bc855ba8d4 12:f62475a73612
   323       };
   323       };
   324 
   324 
   325     };//class Boundingbox
   325     };//class Boundingbox
   326 
   326 
   327 
   327 
       
   328   ///Map of x-coordinates of an xy<>-map
       
   329 
       
   330   ///\ingroup maps
       
   331   ///
       
   332   template<class M>
       
   333   class XMap 
       
   334   {
       
   335     M &_map;
       
   336   public:
       
   337     typedef typename M::Value::Value Value;
       
   338     typedef typename M::Key Key;
       
   339     ///\e
       
   340     XMap(M &map) : _map(map) {}
       
   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));}
       
   343   };
       
   344     
       
   345   ///Returns an \ref XMap class
       
   346 
       
   347   ///This function just returns an \ref XMap class.
       
   348   ///
       
   349   ///\ingroup maps
       
   350   ///\relates XMap
       
   351   template<class M> 
       
   352   inline XMap<M> xMap(M &m) 
       
   353   {
       
   354     return XMap<M>(m);
       
   355   }
       
   356 
       
   357   ///Constant (read only) version of \ref XMap
       
   358 
       
   359   ///\ingroup maps
       
   360   ///
       
   361   template<class M>
       
   362   class ConstXMap 
       
   363   {
       
   364     const M &_map;
       
   365   public:
       
   366     typedef typename M::Value::Value Value;
       
   367     typedef typename M::Key Key;
       
   368     ///\e
       
   369     ConstXMap(const M &map) : _map(map) {}
       
   370     Value operator[](Key k) const {return _map[k].x;}
       
   371   };
       
   372     
       
   373   ///Returns a \ref ConstXMap class
       
   374 
       
   375   ///This function just returns an \ref ConstXMap class.
       
   376   ///
       
   377   ///\ingroup maps
       
   378   ///\relates ConstXMap
       
   379   template<class M> 
       
   380   inline ConstXMap<M> xMap(const M &m) 
       
   381   {
       
   382     return ConstXMap<M>(m);
       
   383   }
       
   384 
       
   385   ///Map of y-coordinates of an xy<>-map
       
   386     
       
   387   ///\ingroup maps
       
   388   ///
       
   389   template<class M>
       
   390   class YMap 
       
   391   {
       
   392     M &_map;
       
   393   public:
       
   394     typedef typename M::Value::Value Value;
       
   395     typedef typename M::Key Key;
       
   396     ///\e
       
   397     YMap(M &map) : _map(map) {}
       
   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));}
       
   400   };
       
   401 
       
   402   ///Returns an \ref YMap class
       
   403 
       
   404   ///This function just returns an \ref YMap class.
       
   405   ///
       
   406   ///\ingroup maps
       
   407   ///\relates YMap
       
   408   template<class M> 
       
   409   inline YMap<M> yMap(M &m) 
       
   410   {
       
   411     return YMap<M>(m);
       
   412   }
       
   413 
       
   414   ///Constant (read only) version of \ref YMap
       
   415 
       
   416   ///\ingroup maps
       
   417   ///
       
   418   template<class M>
       
   419   class ConstYMap 
       
   420   {
       
   421     const M &_map;
       
   422   public:
       
   423     typedef typename M::Value::Value Value;
       
   424     typedef typename M::Key Key;
       
   425     ///\e
       
   426     ConstYMap(const M &map) : _map(map) {}
       
   427     Value operator[](Key k) const {return _map[k].y;}
       
   428   };
       
   429     
       
   430   ///Returns a \ref ConstYMap class
       
   431 
       
   432   ///This function just returns an \ref ConstYMap class.
       
   433   ///
       
   434   ///\ingroup maps
       
   435   ///\relates ConstYMap
       
   436   template<class M> 
       
   437   inline ConstYMap<M> yMap(const M &m) 
       
   438   {
       
   439     return ConstYMap<M>(m);
       
   440   }
       
   441 
       
   442 
   328   /// @}
   443   /// @}
   329 
   444 
   330 
   445 
   331 } //namespace lemon
   446 } //namespace lemon
   332 
   447