- Bugfix in XMap/YMap
authoralpar
Thu, 14 Apr 2005 12:30:18 +0000
changeset 1352bdbb9144a49e
parent 1351 551ffd3bcbb7
child 1353 943fd85a0d2d
- Bugfix in XMap/YMap
- NormSquareMap added
src/lemon/xy.h
     1.1 --- a/src/lemon/xy.h	Thu Apr 14 12:09:35 2005 +0000
     1.2 +++ b/src/lemon/xy.h	Thu Apr 14 12:30:18 2005 +0000
     1.3 @@ -339,7 +339,7 @@
     1.4      ///\e
     1.5      XMap(M &map) : _map(map) {}
     1.6      Value operator[](Key k) const {return _map[k].x;}
     1.7 -    Value set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
     1.8 +    void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
     1.9    };
    1.10      
    1.11    ///Returns an \ref XMap class
    1.12 @@ -396,7 +396,7 @@
    1.13      ///\e
    1.14      YMap(M &map) : _map(map) {}
    1.15      Value operator[](Key k) const {return _map[k].y;}
    1.16 -    Value set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
    1.17 +    void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
    1.18    };
    1.19  
    1.20    ///Returns an \ref YMap class
    1.21 @@ -440,6 +440,35 @@
    1.22    }
    1.23  
    1.24  
    1.25 +  ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map
    1.26 +
    1.27 +  ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map
    1.28 +  ///\ingroup maps
    1.29 +  ///
    1.30 +  template<class M>
    1.31 +  class NormSquareMap 
    1.32 +  {
    1.33 +    const M &_map;
    1.34 +  public:
    1.35 +    typedef typename M::Value::Value Value;
    1.36 +    typedef typename M::Key Key;
    1.37 +    ///\e
    1.38 +    NormSquareMap(const M &map) : _map(map) {}
    1.39 +    Value operator[](Key k) const {return _map[k].normSquare();}
    1.40 +  };
    1.41 +    
    1.42 +  ///Returns a \ref NormSquareMap class
    1.43 +
    1.44 +  ///This function just returns an \ref NormSquareMap class.
    1.45 +  ///
    1.46 +  ///\ingroup maps
    1.47 +  ///\relates NormSquareMap
    1.48 +  template<class M> 
    1.49 +  inline NormSquareMap<M> normSquareMap(const M &m) 
    1.50 +  {
    1.51 +    return NormSquareMap<M>(m);
    1.52 +  }
    1.53 +
    1.54    /// @}
    1.55  
    1.56