1.1 --- a/lemon/maps.h Tue Oct 17 10:50:57 2006 +0000
1.2 +++ b/lemon/maps.h Tue Oct 17 11:01:16 2006 +0000
1.3 @@ -287,6 +287,47 @@
1.4 return ConvertMap<M, T>(m);
1.5 }
1.6
1.7 + ///Simple wrapping of the map
1.8 +
1.9 + ///This \ref concept::ReadMap "read only map" returns the simple
1.10 + ///wrapping of the given map. Sometimes the reference maps cannot be
1.11 + ///combined with simple read maps. This map adaptor wraps the given
1.12 + ///map to simple read map.
1.13 + template<typename M>
1.14 + class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
1.15 + const M& m;
1.16 +
1.17 + public:
1.18 + typedef MapBase<typename M::Key, typename M::Value> Parent;
1.19 + typedef typename Parent::Key Key;
1.20 + typedef typename Parent::Value Value;
1.21 +
1.22 + ///Constructor
1.23 + SimpleMap(const M &_m) : m(_m) {};
1.24 + Value operator[](Key k) const {return m[k];}
1.25 + };
1.26 +
1.27 + ///Simple writeable wrapping of the map
1.28 +
1.29 + ///This \ref concept::ReadMap "read only map" returns the simple
1.30 + ///wrapping of the given map. Sometimes the reference maps cannot be
1.31 + ///combined with simple read-write maps. This map adaptor wraps the
1.32 + ///given map to simple read-write map.
1.33 + template<typename M>
1.34 + class SimpleWriteMap : public MapBase<typename M::Key, typename M::Value> {
1.35 + M& m;
1.36 +
1.37 + public:
1.38 + typedef MapBase<typename M::Key, typename M::Value> Parent;
1.39 + typedef typename Parent::Key Key;
1.40 + typedef typename Parent::Value Value;
1.41 +
1.42 + ///Constructor
1.43 + SimpleWriteMap(M &_m) : m(_m) {};
1.44 + Value operator[](Key k) const {return m[k];}
1.45 + void set(Key k, const Value& c) { m.set(k, c); }
1.46 + };
1.47 +
1.48 ///Sum of two maps
1.49
1.50 ///This \ref concept::ReadMap "read only map" returns the sum of the two