1.1 --- a/src/lemon/xy.h Sat May 14 17:34:31 2005 +0000
1.2 +++ b/src/lemon/xy.h Sat May 14 17:37:33 2005 +0000
1.3 @@ -18,6 +18,7 @@
1.4 #define LEMON_XY_H
1.5
1.6 #include <iostream>
1.7 +#include <lemon/utility.h>
1.8
1.9 ///\ingroup misc
1.10 ///\file
1.11 @@ -350,12 +351,14 @@
1.12 template<class M>
1.13 class XMap
1.14 {
1.15 - M &_map;
1.16 + typename SmartReference<M>::Type _map;
1.17 public:
1.18 + typedef True NeedCopy;
1.19 +
1.20 typedef typename M::Value::Value Value;
1.21 typedef typename M::Key Key;
1.22 ///\e
1.23 - XMap(M &map) : _map(map) {}
1.24 + XMap(typename SmartParameter<M>::Type map) : _map(map) {}
1.25 Value operator[](Key k) const {return _map[k].x;}
1.26 void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
1.27 };
1.28 @@ -372,6 +375,12 @@
1.29 return XMap<M>(m);
1.30 }
1.31
1.32 + template<class M>
1.33 + inline XMap<M> xMap(const M &m)
1.34 + {
1.35 + return XMap<M>(m);
1.36 + }
1.37 +
1.38 ///Constant (read only) version of \ref XMap
1.39
1.40 ///\ingroup maps
1.41 @@ -379,8 +388,10 @@
1.42 template<class M>
1.43 class ConstXMap
1.44 {
1.45 - const M &_map;
1.46 + typename SmartConstReference<M>::Type _map;
1.47 public:
1.48 + typedef True NeedCopy;
1.49 +
1.50 typedef typename M::Value::Value Value;
1.51 typedef typename M::Key Key;
1.52 ///\e
1.53 @@ -407,12 +418,14 @@
1.54 template<class M>
1.55 class YMap
1.56 {
1.57 - M &_map;
1.58 + typename SmartReference<M>::Type _map;
1.59 public:
1.60 + typedef True NeedCopy;
1.61 +
1.62 typedef typename M::Value::Value Value;
1.63 typedef typename M::Key Key;
1.64 ///\e
1.65 - YMap(M &map) : _map(map) {}
1.66 + YMap(typename SmartParameter<M>::Type map) : _map(map) {}
1.67 Value operator[](Key k) const {return _map[k].y;}
1.68 void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));}
1.69 };
1.70 @@ -429,6 +442,12 @@
1.71 return YMap<M>(m);
1.72 }
1.73
1.74 + template<class M>
1.75 + inline YMap<M> yMap(const M &m)
1.76 + {
1.77 + return YMap<M>(m);
1.78 + }
1.79 +
1.80 ///Constant (read only) version of \ref YMap
1.81
1.82 ///\ingroup maps
1.83 @@ -436,8 +455,10 @@
1.84 template<class M>
1.85 class ConstYMap
1.86 {
1.87 - const M &_map;
1.88 + typename SmartConstReference<M>::Type _map;
1.89 public:
1.90 + typedef True NeedCopy;
1.91 +
1.92 typedef typename M::Value::Value Value;
1.93 typedef typename M::Key Key;
1.94 ///\e
1.95 @@ -466,8 +487,10 @@
1.96 template<class M>
1.97 class NormSquareMap
1.98 {
1.99 - const M &_map;
1.100 + typename SmartConstReference<M>::Type _map;
1.101 public:
1.102 + typedef True NeedCopy;
1.103 +
1.104 typedef typename M::Value::Value Value;
1.105 typedef typename M::Key Key;
1.106 ///\e