- XMap and YMap added
authoralpar
Thu, 07 Apr 2005 11:30:12 +0000
changeset 131783f80464f111
parent 1316 daaf6b5c28d6
child 1318 88edb143a87a
- XMap and YMap added
- Spell checking
src/lemon/maps.h
src/lemon/xy.h
     1.1 --- a/src/lemon/maps.h	Thu Apr 07 10:44:32 2005 +0000
     1.2 +++ b/src/lemon/maps.h	Thu Apr 07 11:30:12 2005 +0000
     1.3 @@ -742,7 +742,7 @@
     1.4    ///parameters and each write request will be passed to both of them.
     1.5    ///If \c M1 is also \ref concept::ReadMap "readable",
     1.6    ///then the read operations will return the
     1.7 -  ///corresponding values \c M1.
     1.8 +  ///corresponding values of \c M1.
     1.9    ///
    1.10    ///The \c Key and \c Value will be inherited from \c M1.
    1.11    ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
     2.1 --- a/src/lemon/xy.h	Thu Apr 07 10:44:32 2005 +0000
     2.2 +++ b/src/lemon/xy.h	Thu Apr 07 11:30:12 2005 +0000
     2.3 @@ -325,6 +325,121 @@
     2.4      };//class Boundingbox
     2.5  
     2.6  
     2.7 +  ///Map of x-coordinates of an xy<>-map
     2.8 +
     2.9 +  ///\ingroup maps
    2.10 +  ///
    2.11 +  template<class M>
    2.12 +  class XMap 
    2.13 +  {
    2.14 +    M &_map;
    2.15 +  public:
    2.16 +    typedef typename M::Value::Value Value;
    2.17 +    typedef typename M::Key Key;
    2.18 +    ///\e
    2.19 +    XMap(M &map) : _map(map) {}
    2.20 +    Value operator[](Key k) const {return _map[k].x;}
    2.21 +    Value set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
    2.22 +  };
    2.23 +    
    2.24 +  ///Returns an \ref XMap class
    2.25 +
    2.26 +  ///This function just returns an \ref XMap class.
    2.27 +  ///
    2.28 +  ///\ingroup maps
    2.29 +  ///\relates XMap
    2.30 +  template<class M> 
    2.31 +  inline XMap<M> xMap(M &m) 
    2.32 +  {
    2.33 +    return XMap<M>(m);
    2.34 +  }
    2.35 +
    2.36 +  ///Constant (read only) version of \ref XMap
    2.37 +
    2.38 +  ///\ingroup maps
    2.39 +  ///
    2.40 +  template<class M>
    2.41 +  class ConstXMap 
    2.42 +  {
    2.43 +    const M &_map;
    2.44 +  public:
    2.45 +    typedef typename M::Value::Value Value;
    2.46 +    typedef typename M::Key Key;
    2.47 +    ///\e
    2.48 +    ConstXMap(const M &map) : _map(map) {}
    2.49 +    Value operator[](Key k) const {return _map[k].x;}
    2.50 +  };
    2.51 +    
    2.52 +  ///Returns a \ref ConstXMap class
    2.53 +
    2.54 +  ///This function just returns an \ref ConstXMap class.
    2.55 +  ///
    2.56 +  ///\ingroup maps
    2.57 +  ///\relates ConstXMap
    2.58 +  template<class M> 
    2.59 +  inline ConstXMap<M> xMap(const M &m) 
    2.60 +  {
    2.61 +    return ConstXMap<M>(m);
    2.62 +  }
    2.63 +
    2.64 +  ///Map of y-coordinates of an xy<>-map
    2.65 +    
    2.66 +  ///\ingroup maps
    2.67 +  ///
    2.68 +  template<class M>
    2.69 +  class YMap 
    2.70 +  {
    2.71 +    M &_map;
    2.72 +  public:
    2.73 +    typedef typename M::Value::Value Value;
    2.74 +    typedef typename M::Key Key;
    2.75 +    ///\e
    2.76 +    YMap(M &map) : _map(map) {}
    2.77 +    Value operator[](Key k) const {return _map[k].y;}
    2.78 +    Value set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
    2.79 +  };
    2.80 +
    2.81 +  ///Returns an \ref YMap class
    2.82 +
    2.83 +  ///This function just returns an \ref YMap class.
    2.84 +  ///
    2.85 +  ///\ingroup maps
    2.86 +  ///\relates YMap
    2.87 +  template<class M> 
    2.88 +  inline YMap<M> yMap(M &m) 
    2.89 +  {
    2.90 +    return YMap<M>(m);
    2.91 +  }
    2.92 +
    2.93 +  ///Constant (read only) version of \ref YMap
    2.94 +
    2.95 +  ///\ingroup maps
    2.96 +  ///
    2.97 +  template<class M>
    2.98 +  class ConstYMap 
    2.99 +  {
   2.100 +    const M &_map;
   2.101 +  public:
   2.102 +    typedef typename M::Value::Value Value;
   2.103 +    typedef typename M::Key Key;
   2.104 +    ///\e
   2.105 +    ConstYMap(const M &map) : _map(map) {}
   2.106 +    Value operator[](Key k) const {return _map[k].y;}
   2.107 +  };
   2.108 +    
   2.109 +  ///Returns a \ref ConstYMap class
   2.110 +
   2.111 +  ///This function just returns an \ref ConstYMap class.
   2.112 +  ///
   2.113 +  ///\ingroup maps
   2.114 +  ///\relates ConstYMap
   2.115 +  template<class M> 
   2.116 +  inline ConstYMap<M> yMap(const M &m) 
   2.117 +  {
   2.118 +    return ConstYMap<M>(m);
   2.119 +  }
   2.120 +
   2.121 +
   2.122    /// @}
   2.123  
   2.124