# HG changeset patch # User alpar # Date 1112873412 0 # Node ID 83f80464f1113ec0b7e7ea064ec7b17f464161ef # Parent daaf6b5c28d69faca80c437cdeaa2c1b80b57a96 - XMap and YMap added - Spell checking diff -r daaf6b5c28d6 -r 83f80464f111 src/lemon/maps.h --- a/src/lemon/maps.h Thu Apr 07 10:44:32 2005 +0000 +++ b/src/lemon/maps.h Thu Apr 07 11:30:12 2005 +0000 @@ -742,7 +742,7 @@ ///parameters and each write request will be passed to both of them. ///If \c M1 is also \ref concept::ReadMap "readable", ///then the read operations will return the - ///corresponding values \c M1. + ///corresponding values of \c M1. /// ///The \c Key and \c Value will be inherited from \c M1. ///The \c Key and \c Value of M2 must be convertible from those of \c M1. diff -r daaf6b5c28d6 -r 83f80464f111 src/lemon/xy.h --- a/src/lemon/xy.h Thu Apr 07 10:44:32 2005 +0000 +++ b/src/lemon/xy.h Thu Apr 07 11:30:12 2005 +0000 @@ -325,6 +325,121 @@ };//class Boundingbox + ///Map of x-coordinates of an xy<>-map + + ///\ingroup maps + /// + template + class XMap + { + M &_map; + public: + typedef typename M::Value::Value Value; + typedef typename M::Key Key; + ///\e + XMap(M &map) : _map(map) {} + Value operator[](Key k) const {return _map[k].x;} + Value set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));} + }; + + ///Returns an \ref XMap class + + ///This function just returns an \ref XMap class. + /// + ///\ingroup maps + ///\relates XMap + template + inline XMap xMap(M &m) + { + return XMap(m); + } + + ///Constant (read only) version of \ref XMap + + ///\ingroup maps + /// + template + class ConstXMap + { + const M &_map; + public: + typedef typename M::Value::Value Value; + typedef typename M::Key Key; + ///\e + ConstXMap(const M &map) : _map(map) {} + Value operator[](Key k) const {return _map[k].x;} + }; + + ///Returns a \ref ConstXMap class + + ///This function just returns an \ref ConstXMap class. + /// + ///\ingroup maps + ///\relates ConstXMap + template + inline ConstXMap xMap(const M &m) + { + return ConstXMap(m); + } + + ///Map of y-coordinates of an xy<>-map + + ///\ingroup maps + /// + template + class YMap + { + M &_map; + public: + typedef typename M::Value::Value Value; + typedef typename M::Key Key; + ///\e + YMap(M &map) : _map(map) {} + Value operator[](Key k) const {return _map[k].y;} + Value set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));} + }; + + ///Returns an \ref YMap class + + ///This function just returns an \ref YMap class. + /// + ///\ingroup maps + ///\relates YMap + template + inline YMap yMap(M &m) + { + return YMap(m); + } + + ///Constant (read only) version of \ref YMap + + ///\ingroup maps + /// + template + class ConstYMap + { + const M &_map; + public: + typedef typename M::Value::Value Value; + typedef typename M::Key Key; + ///\e + ConstYMap(const M &map) : _map(map) {} + Value operator[](Key k) const {return _map[k].y;} + }; + + ///Returns a \ref ConstYMap class + + ///This function just returns an \ref ConstYMap class. + /// + ///\ingroup maps + ///\relates ConstYMap + template + inline ConstYMap yMap(const M &m) + { + return ConstYMap(m); + } + + /// @}