lemon/xy.h
changeset 1853 dd0b47adc152
parent 1588 b79bcba43661
child 1875 98698b69a902
equal deleted inserted replaced
1:4413804cc849 2:57701c88408c
   362   ///\ingroup maps
   362   ///\ingroup maps
   363   ///
   363   ///
   364   template<class M>
   364   template<class M>
   365   class XMap 
   365   class XMap 
   366   {
   366   {
   367     typename SmartReference<M>::Type _map;
   367     M& _map;
   368   public:
   368   public:
   369     typedef True NeedCopy;
       
   370 
   369 
   371     typedef typename M::Value::Value Value;
   370     typedef typename M::Value::Value Value;
   372     typedef typename M::Key Key;
   371     typedef typename M::Key Key;
   373     ///\e
   372     ///\e
   374     XMap(typename SmartParameter<M>::Type map) : _map(map) {}
   373     XMap(M& map) : _map(map) {}
   375     Value operator[](Key k) const {return _map[k].x;}
   374     Value operator[](Key k) const {return _map[k].x;}
   376     void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
   375     void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
   377   };
   376   };
   378     
   377     
   379   ///Returns an \ref XMap class
   378   ///Returns an \ref XMap class
   399   ///\ingroup maps
   398   ///\ingroup maps
   400   ///
   399   ///
   401   template<class M>
   400   template<class M>
   402   class ConstXMap 
   401   class ConstXMap 
   403   {
   402   {
   404     typename SmartConstReference<M>::Type _map;
   403     const M& _map;
   405   public:
   404   public:
   406     typedef True NeedCopy;
       
   407 
   405 
   408     typedef typename M::Value::Value Value;
   406     typedef typename M::Value::Value Value;
   409     typedef typename M::Key Key;
   407     typedef typename M::Key Key;
   410     ///\e
   408     ///\e
   411     ConstXMap(const M &map) : _map(map) {}
   409     ConstXMap(const M &map) : _map(map) {}
   429   ///\ingroup maps
   427   ///\ingroup maps
   430   ///
   428   ///
   431   template<class M>
   429   template<class M>
   432   class YMap 
   430   class YMap 
   433   {
   431   {
   434     typename SmartReference<M>::Type _map;
   432     M& _map;
   435   public:
   433   public:
   436     typedef True NeedCopy;
       
   437 
   434 
   438     typedef typename M::Value::Value Value;
   435     typedef typename M::Value::Value Value;
   439     typedef typename M::Key Key;
   436     typedef typename M::Key Key;
   440     ///\e
   437     ///\e
   441     YMap(typename SmartParameter<M>::Type map) : _map(map) {}
   438     YMap(M& map) : _map(map) {}
   442     Value operator[](Key k) const {return _map[k].y;}
   439     Value operator[](Key k) const {return _map[k].y;}
   443     void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
   440     void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
   444   };
   441   };
   445 
   442 
   446   ///Returns an \ref YMap class
   443   ///Returns an \ref YMap class
   466   ///\ingroup maps
   463   ///\ingroup maps
   467   ///
   464   ///
   468   template<class M>
   465   template<class M>
   469   class ConstYMap 
   466   class ConstYMap 
   470   {
   467   {
   471     typename SmartConstReference<M>::Type _map;
   468     const M& _map;
   472   public:
   469   public:
   473     typedef True NeedCopy;
       
   474 
   470 
   475     typedef typename M::Value::Value Value;
   471     typedef typename M::Value::Value Value;
   476     typedef typename M::Key Key;
   472     typedef typename M::Key Key;
   477     ///\e
   473     ///\e
   478     ConstYMap(const M &map) : _map(map) {}
   474     ConstYMap(const M &map) : _map(map) {}
   498   ///\ingroup maps
   494   ///\ingroup maps
   499   ///
   495   ///
   500   template<class M>
   496   template<class M>
   501   class NormSquareMap 
   497   class NormSquareMap 
   502   {
   498   {
   503     typename SmartConstReference<M>::Type _map;
   499     const M& _map;
   504   public:
   500   public:
   505     typedef True NeedCopy;
       
   506 
   501 
   507     typedef typename M::Value::Value Value;
   502     typedef typename M::Value::Value Value;
   508     typedef typename M::Key Key;
   503     typedef typename M::Key Key;
   509     ///\e
   504     ///\e
   510     NormSquareMap(const M &map) : _map(map) {}
   505     NormSquareMap(const M &map) : _map(map) {}