src/lemon/xy.h
changeset 1317 83f80464f111
parent 1257 7101e2c3a881
child 1352 bdbb9144a49e
     1.1 --- a/src/lemon/xy.h	Thu Apr 07 10:44:32 2005 +0000
     1.2 +++ b/src/lemon/xy.h	Thu Apr 07 11:30:12 2005 +0000
     1.3 @@ -325,6 +325,121 @@
     1.4      };//class Boundingbox
     1.5  
     1.6  
     1.7 +  ///Map of x-coordinates of an xy<>-map
     1.8 +
     1.9 +  ///\ingroup maps
    1.10 +  ///
    1.11 +  template<class M>
    1.12 +  class XMap 
    1.13 +  {
    1.14 +    M &_map;
    1.15 +  public:
    1.16 +    typedef typename M::Value::Value Value;
    1.17 +    typedef typename M::Key Key;
    1.18 +    ///\e
    1.19 +    XMap(M &map) : _map(map) {}
    1.20 +    Value operator[](Key k) const {return _map[k].x;}
    1.21 +    Value set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
    1.22 +  };
    1.23 +    
    1.24 +  ///Returns an \ref XMap class
    1.25 +
    1.26 +  ///This function just returns an \ref XMap class.
    1.27 +  ///
    1.28 +  ///\ingroup maps
    1.29 +  ///\relates XMap
    1.30 +  template<class M> 
    1.31 +  inline XMap<M> xMap(M &m) 
    1.32 +  {
    1.33 +    return XMap<M>(m);
    1.34 +  }
    1.35 +
    1.36 +  ///Constant (read only) version of \ref XMap
    1.37 +
    1.38 +  ///\ingroup maps
    1.39 +  ///
    1.40 +  template<class M>
    1.41 +  class ConstXMap 
    1.42 +  {
    1.43 +    const M &_map;
    1.44 +  public:
    1.45 +    typedef typename M::Value::Value Value;
    1.46 +    typedef typename M::Key Key;
    1.47 +    ///\e
    1.48 +    ConstXMap(const M &map) : _map(map) {}
    1.49 +    Value operator[](Key k) const {return _map[k].x;}
    1.50 +  };
    1.51 +    
    1.52 +  ///Returns a \ref ConstXMap class
    1.53 +
    1.54 +  ///This function just returns an \ref ConstXMap class.
    1.55 +  ///
    1.56 +  ///\ingroup maps
    1.57 +  ///\relates ConstXMap
    1.58 +  template<class M> 
    1.59 +  inline ConstXMap<M> xMap(const M &m) 
    1.60 +  {
    1.61 +    return ConstXMap<M>(m);
    1.62 +  }
    1.63 +
    1.64 +  ///Map of y-coordinates of an xy<>-map
    1.65 +    
    1.66 +  ///\ingroup maps
    1.67 +  ///
    1.68 +  template<class M>
    1.69 +  class YMap 
    1.70 +  {
    1.71 +    M &_map;
    1.72 +  public:
    1.73 +    typedef typename M::Value::Value Value;
    1.74 +    typedef typename M::Key Key;
    1.75 +    ///\e
    1.76 +    YMap(M &map) : _map(map) {}
    1.77 +    Value operator[](Key k) const {return _map[k].y;}
    1.78 +    Value set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
    1.79 +  };
    1.80 +
    1.81 +  ///Returns an \ref YMap class
    1.82 +
    1.83 +  ///This function just returns an \ref YMap class.
    1.84 +  ///
    1.85 +  ///\ingroup maps
    1.86 +  ///\relates YMap
    1.87 +  template<class M> 
    1.88 +  inline YMap<M> yMap(M &m) 
    1.89 +  {
    1.90 +    return YMap<M>(m);
    1.91 +  }
    1.92 +
    1.93 +  ///Constant (read only) version of \ref YMap
    1.94 +
    1.95 +  ///\ingroup maps
    1.96 +  ///
    1.97 +  template<class M>
    1.98 +  class ConstYMap 
    1.99 +  {
   1.100 +    const M &_map;
   1.101 +  public:
   1.102 +    typedef typename M::Value::Value Value;
   1.103 +    typedef typename M::Key Key;
   1.104 +    ///\e
   1.105 +    ConstYMap(const M &map) : _map(map) {}
   1.106 +    Value operator[](Key k) const {return _map[k].y;}
   1.107 +  };
   1.108 +    
   1.109 +  ///Returns a \ref ConstYMap class
   1.110 +
   1.111 +  ///This function just returns an \ref ConstYMap class.
   1.112 +  ///
   1.113 +  ///\ingroup maps
   1.114 +  ///\relates ConstYMap
   1.115 +  template<class M> 
   1.116 +  inline ConstYMap<M> yMap(const M &m) 
   1.117 +  {
   1.118 +    return ConstYMap<M>(m);
   1.119 +  }
   1.120 +
   1.121 +
   1.122    /// @}
   1.123  
   1.124