Overall clean-up in maps.h
authorPeter Kovacs <kpeter@inf.elte.hu>
Sat, 15 Mar 2008 21:07:24 +0100
changeset 8015968e25ca08
parent 79 d73c2e8b25cb
child 81 7ff1c348ae0c
Overall clean-up in maps.h

- Rename some map types:
* IntegerMap -> RangeMap
* StdMap -> SparseMap
* FunctorMap -> FunctorToMap
* MapFunctor -> MapToFunctor
* ForkWriteMap -> ForkMap
* SimpleMap -> WrapMap
* SimpleWriteMap -> WrapWriteMap
- Remove the read-only ForkMap version.
- Rename map-creator functions for the read-write arithmetic and
logical maps.
- Small fixes and improvements in the code.
- Fix the typedefs of RangeMap to work correctly with bool type, too.
- Rename template parameters, function parameters, and private members
in many classes to be uniform and to avoid parameter names starting
with underscore.
- Use Key and Value types instead of K and V template parameters in
public functions.
- Extend the documentation with examples (e.g. for basic arithmetic and
logical maps).
- Many doc improvements.
- Reorder the classes.
- StoreBoolMap, BackInserterBoolMap, FrontInserterBoolMap,
InserterBoolMap, FillBoolMap, SettingOrderBoolMap are almost unchanged,
since they will be removed.
- Also improve maps_test.cc to correctly check every map class, every
constructor, and every creator function.
lemon/maps.h
test/maps_test.cc
     1.1 --- a/lemon/maps.h	Sat Mar 15 20:21:21 2008 +0100
     1.2 +++ b/lemon/maps.h	Sat Mar 15 21:07:24 2008 +0100
     1.3 @@ -24,12 +24,12 @@
     1.4  #include <vector>
     1.5  
     1.6  #include <lemon/bits/utility.h>
     1.7 -// #include <lemon/bits/traits.h>
     1.8 +#include <lemon/bits/traits.h>
     1.9  
    1.10  ///\file
    1.11  ///\ingroup maps
    1.12  ///\brief Miscellaneous property maps
    1.13 -///
    1.14 +
    1.15  #include <map>
    1.16  
    1.17  namespace lemon {
    1.18 @@ -39,41 +39,46 @@
    1.19  
    1.20    /// Base class of maps.
    1.21  
    1.22 -  /// Base class of maps.
    1.23 -  /// It provides the necessary <tt>typedef</tt>s required by the map concept.
    1.24 -  template<typename K, typename T>
    1.25 +  /// Base class of maps. It provides the necessary type definitions
    1.26 +  /// required by the map %concepts.
    1.27 +  template<typename K, typename V>
    1.28    class MapBase {
    1.29    public:
    1.30 -    /// The key type of the map.
    1.31 +    /// \biref The key type of the map.
    1.32      typedef K Key;
    1.33 -    /// The value type of the map. (The type of objects associated with the keys).
    1.34 -    typedef T Value;
    1.35 +    /// \brief The value type of the map.
    1.36 +    /// (The type of objects associated with the keys).
    1.37 +    typedef V Value;
    1.38    };
    1.39  
    1.40 +
    1.41    /// Null map. (a.k.a. DoNothingMap)
    1.42  
    1.43    /// This map can be used if you have to provide a map only for
    1.44 -  /// its type definitions, or if you have to provide a writable map, 
    1.45 -  /// but data written to it is not required (i.e. it will be sent to 
    1.46 +  /// its type definitions, or if you have to provide a writable map,
    1.47 +  /// but data written to it is not required (i.e. it will be sent to
    1.48    /// <tt>/dev/null</tt>).
    1.49 -  template<typename K, typename T>
    1.50 -  class NullMap : public MapBase<K, T> {
    1.51 +  /// It conforms the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    1.52 +  ///
    1.53 +  /// \sa ConstMap
    1.54 +  template<typename K, typename V>
    1.55 +  class NullMap : public MapBase<K, V> {
    1.56    public:
    1.57 -    typedef MapBase<K, T> Parent;
    1.58 +    typedef MapBase<K, V> Parent;
    1.59      typedef typename Parent::Key Key;
    1.60      typedef typename Parent::Value Value;
    1.61 -    
    1.62 +
    1.63      /// Gives back a default constructed element.
    1.64 -    T operator[](const K&) const { return T(); }
    1.65 +    Value operator[](const Key&) const { return Value(); }
    1.66      /// Absorbs the value.
    1.67 -    void set(const K&, const T&) {}
    1.68 +    void set(const Key&, const Value&) {}
    1.69    };
    1.70  
    1.71 -  ///Returns a \c NullMap class
    1.72 +  /// Returns a \ref NullMap class
    1.73  
    1.74 -  ///This function just returns a \c NullMap class.
    1.75 -  ///\relates NullMap
    1.76 -  template <typename K, typename V> 
    1.77 +  /// This function just returns a \ref NullMap class.
    1.78 +  /// \relates NullMap
    1.79 +  template <typename K, typename V>
    1.80    NullMap<K, V> nullMap() {
    1.81      return NullMap<K, V>();
    1.82    }
    1.83 @@ -81,62 +86,81 @@
    1.84  
    1.85    /// Constant map.
    1.86  
    1.87 -  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
    1.88 +  /// This is a \ref concepts::ReadMap "readable" map which assigns a
    1.89    /// specified value to each key.
    1.90 -  /// In other aspects it is equivalent to \c NullMap.
    1.91 -  template<typename K, typename T>
    1.92 -  class ConstMap : public MapBase<K, T> {
    1.93 +  ///
    1.94 +  /// In other aspects it is equivalent to \ref NullMap.
    1.95 +  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
    1.96 +  /// concept, but it absorbs the data written to it.
    1.97 +  ///
    1.98 +  /// The simplest way of using this map is through the constMap()
    1.99 +  /// function.
   1.100 +  ///
   1.101 +  /// \sa NullMap
   1.102 +  /// \sa IdentityMap
   1.103 +  template<typename K, typename V>
   1.104 +  class ConstMap : public MapBase<K, V> {
   1.105    private:
   1.106 -    T v;
   1.107 +    V _value;
   1.108    public:
   1.109 -
   1.110 -    typedef MapBase<K, T> Parent;
   1.111 +    typedef MapBase<K, V> Parent;
   1.112      typedef typename Parent::Key Key;
   1.113      typedef typename Parent::Value Value;
   1.114  
   1.115      /// Default constructor
   1.116  
   1.117      /// Default constructor.
   1.118 -    /// The value of the map will be uninitialized. 
   1.119 -    /// (More exactly it will be default constructed.)
   1.120 +    /// The value of the map will be default constructed.
   1.121      ConstMap() {}
   1.122 -    
   1.123 +
   1.124      /// Constructor with specified initial value
   1.125  
   1.126      /// Constructor with specified initial value.
   1.127 -    /// \param _v is the initial value of the map.
   1.128 -    ConstMap(const T &_v) : v(_v) {}
   1.129 -    
   1.130 -    ///\e
   1.131 -    T operator[](const K&) const { return v; }
   1.132 +    /// \param v is the initial value of the map.
   1.133 +    ConstMap(const Value &v) : _value(v) {}
   1.134  
   1.135 -    ///\e
   1.136 -    void setAll(const T &t) {
   1.137 -      v = t;
   1.138 -    }    
   1.139 +    /// Gives back the specified value.
   1.140 +    Value operator[](const Key&) const { return _value; }
   1.141  
   1.142 -    template<typename T1>
   1.143 -    ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
   1.144 +    /// Absorbs the value.
   1.145 +    void set(const Key&, const Value&) {}
   1.146 +
   1.147 +    /// Sets the value that is assigned to each key.
   1.148 +    void setAll(const Value &v) {
   1.149 +      _value = v;
   1.150 +    }
   1.151 +
   1.152 +    template<typename V1>
   1.153 +    ConstMap(const ConstMap<K, V1> &, const Value &v) : _value(v) {}
   1.154    };
   1.155  
   1.156 -  ///Returns a \c ConstMap class
   1.157 +  /// Returns a \ref ConstMap class
   1.158  
   1.159 -  ///This function just returns a \c ConstMap class.
   1.160 -  ///\relates ConstMap
   1.161 -  template<typename K, typename V> 
   1.162 +  /// This function just returns a \ref ConstMap class.
   1.163 +  /// \relates ConstMap
   1.164 +  template<typename K, typename V>
   1.165    inline ConstMap<K, V> constMap(const V &v) {
   1.166      return ConstMap<K, V>(v);
   1.167    }
   1.168  
   1.169  
   1.170    template<typename T, T v>
   1.171 -  struct Const { };
   1.172 +  struct Const {};
   1.173  
   1.174    /// Constant map with inlined constant value.
   1.175  
   1.176 -  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
   1.177 +  /// This is a \ref concepts::ReadMap "readable" map which assigns a
   1.178    /// specified value to each key.
   1.179 -  /// In other aspects it is equivalent to \c NullMap.
   1.180 +  ///
   1.181 +  /// In other aspects it is equivalent to \ref NullMap.
   1.182 +  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
   1.183 +  /// concept, but it absorbs the data written to it.
   1.184 +  ///
   1.185 +  /// The simplest way of using this map is through the constMap()
   1.186 +  /// function.
   1.187 +  ///
   1.188 +  /// \sa NullMap
   1.189 +  /// \sa IdentityMap
   1.190    template<typename K, typename V, V v>
   1.191    class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
   1.192    public:
   1.193 @@ -144,69 +168,230 @@
   1.194      typedef typename Parent::Key Key;
   1.195      typedef typename Parent::Value Value;
   1.196  
   1.197 -    ConstMap() { }
   1.198 -    ///\e
   1.199 -    V operator[](const K&) const { return v; }
   1.200 -    ///\e
   1.201 -    void set(const K&, const V&) { }
   1.202 +    /// Constructor.
   1.203 +    ConstMap() {}
   1.204 +
   1.205 +    /// Gives back the specified value.
   1.206 +    Value operator[](const Key&) const { return v; }
   1.207 +
   1.208 +    /// Absorbs the value.
   1.209 +    void set(const Key&, const Value&) {}
   1.210    };
   1.211  
   1.212 -  ///Returns a \c ConstMap class with inlined value
   1.213 +  /// Returns a \ref ConstMap class with inlined constant value
   1.214  
   1.215 -  ///This function just returns a \c ConstMap class with inlined value.
   1.216 -  ///\relates ConstMap
   1.217 -  template<typename K, typename V, V v> 
   1.218 +  /// This function just returns a \ref ConstMap class with inlined
   1.219 +  /// constant value.
   1.220 +  /// \relates ConstMap
   1.221 +  template<typename K, typename V, V v>
   1.222    inline ConstMap<K, Const<V, v> > constMap() {
   1.223      return ConstMap<K, Const<V, v> >();
   1.224    }
   1.225  
   1.226 -  ///Map based on \c std::map
   1.227  
   1.228 -  ///This is essentially a wrapper for \c std::map with addition that
   1.229 -  ///you can specify a default value different from \c Value().
   1.230 -  ///It meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
   1.231 -  template <typename K, typename T, typename Compare = std::less<K> >
   1.232 -  class StdMap : public MapBase<K, T> {
   1.233 -    template <typename K1, typename T1, typename C1>
   1.234 -    friend class StdMap;
   1.235 +  /// \brief Identity map.
   1.236 +  ///
   1.237 +  /// This map gives back the given key as value without any
   1.238 +  /// modification.
   1.239 +  ///
   1.240 +  /// \sa ConstMap
   1.241 +  template <typename T>
   1.242 +  class IdentityMap : public MapBase<T, T> {
   1.243 +  public:
   1.244 +    typedef MapBase<T, T> Parent;
   1.245 +    typedef typename Parent::Key Key;
   1.246 +    typedef typename Parent::Value Value;
   1.247 +
   1.248 +    /// Gives back the given value without any modification.
   1.249 +    const T& operator[](const T& t) const {
   1.250 +      return t;
   1.251 +    }
   1.252 +  };
   1.253 +
   1.254 +  /// Returns an \ref IdentityMap class
   1.255 +
   1.256 +  /// This function just returns an \ref IdentityMap class.
   1.257 +  /// \relates IdentityMap
   1.258 +  template<typename T>
   1.259 +  inline IdentityMap<T> identityMap() {
   1.260 +    return IdentityMap<T>();
   1.261 +  }
   1.262 +
   1.263 +
   1.264 +  /// \brief Map for storing values for integer keys from the range
   1.265 +  /// <tt>[0..size-1]</tt>.
   1.266 +  ///
   1.267 +  /// This map is essentially a wrapper for \c std::vector. It assigns
   1.268 +  /// values to integer keys from the range <tt>[0..size-1]</tt>.
   1.269 +  /// It can be used with some data structures, for example
   1.270 +  /// \ref UnionFind, \ref BinHeap, when the used items are small
   1.271 +  /// integers. This map conforms the \ref concepts::ReferenceMap
   1.272 +  /// "ReferenceMap" concept.
   1.273 +  ///
   1.274 +  /// The simplest way of using this map is through the rangeMap()
   1.275 +  /// function.
   1.276 +  template <typename V>
   1.277 +  class RangeMap : public MapBase<int, V> {
   1.278 +    template <typename V1>
   1.279 +    friend class RangeMap;
   1.280 +  private:
   1.281 +
   1.282 +    typedef std::vector<V> Vector;
   1.283 +    Vector _vector;
   1.284 +
   1.285    public:
   1.286  
   1.287 -    typedef MapBase<K, T> Parent;
   1.288 -    ///Key type
   1.289 +    typedef MapBase<int, V> Parent;
   1.290 +    /// Key type
   1.291      typedef typename Parent::Key Key;
   1.292 -    ///Value type
   1.293 +    /// Value type
   1.294      typedef typename Parent::Value Value;
   1.295 -    ///Reference Type
   1.296 -    typedef T& Reference;
   1.297 -    ///Const reference type
   1.298 -    typedef const T& ConstReference;
   1.299 +    /// Reference type
   1.300 +    typedef typename Vector::reference Reference;
   1.301 +    /// Const reference type
   1.302 +    typedef typename Vector::const_reference ConstReference;
   1.303 +
   1.304 +    typedef True ReferenceMapTag;
   1.305 +
   1.306 +  public:
   1.307 +
   1.308 +    /// Constructor with specified default value.
   1.309 +    RangeMap(int size = 0, const Value &value = Value())
   1.310 +      : _vector(size, value) {}
   1.311 +
   1.312 +    /// Constructs the map from an appropriate \c std::vector.
   1.313 +    template <typename V1>
   1.314 +    RangeMap(const std::vector<V1>& vector)
   1.315 +      : _vector(vector.begin(), vector.end()) {}
   1.316 +
   1.317 +    /// Constructs the map from another \ref RangeMap.
   1.318 +    template <typename V1>
   1.319 +    RangeMap(const RangeMap<V1> &c)
   1.320 +      : _vector(c._vector.begin(), c._vector.end()) {}
   1.321 +
   1.322 +    /// Returns the size of the map.
   1.323 +    int size() {
   1.324 +      return _vector.size();
   1.325 +    }
   1.326 +
   1.327 +    /// Resizes the map.
   1.328 +
   1.329 +    /// Resizes the underlying \c std::vector container, so changes the
   1.330 +    /// keyset of the map.
   1.331 +    /// \param size The new size of the map. The new keyset will be the
   1.332 +    /// range <tt>[0..size-1]</tt>.
   1.333 +    /// \param value The default value to assign to the new keys.
   1.334 +    void resize(int size, const Value &value = Value()) {
   1.335 +      _vector.resize(size, value);
   1.336 +    }
   1.337 +
   1.338 +  private:
   1.339 +
   1.340 +    RangeMap& operator=(const RangeMap&);
   1.341 +
   1.342 +  public:
   1.343 +
   1.344 +    ///\e
   1.345 +    Reference operator[](const Key &k) {
   1.346 +      return _vector[k];
   1.347 +    }
   1.348 +
   1.349 +    ///\e
   1.350 +    ConstReference operator[](const Key &k) const {
   1.351 +      return _vector[k];
   1.352 +    }
   1.353 +
   1.354 +    ///\e
   1.355 +    void set(const Key &k, const Value &v) {
   1.356 +      _vector[k] = v;
   1.357 +    }
   1.358 +  };
   1.359 +
   1.360 +  /// Returns a \ref RangeMap class
   1.361 +
   1.362 +  /// This function just returns a \ref RangeMap class.
   1.363 +  /// \relates RangeMap
   1.364 +  template<typename V>
   1.365 +  inline RangeMap<V> rangeMap(int size = 0, const V &value = V()) {
   1.366 +    return RangeMap<V>(size, value);
   1.367 +  }
   1.368 +
   1.369 +  /// \brief Returns a \ref RangeMap class created from an appropriate
   1.370 +  /// \c std::vector
   1.371 +
   1.372 +  /// This function just returns a \ref RangeMap class created from an
   1.373 +  /// appropriate \c std::vector.
   1.374 +  /// \relates RangeMap
   1.375 +  template<typename V>
   1.376 +  inline RangeMap<V> rangeMap(const std::vector<V> &vector) {
   1.377 +    return RangeMap<V>(vector);
   1.378 +  }
   1.379 +
   1.380 +
   1.381 +  /// Map type based on \c std::map
   1.382 +
   1.383 +  /// This map is essentially a wrapper for \c std::map with addition
   1.384 +  /// that you can specify a default value for the keys that are not
   1.385 +  /// stored actually. This value can be different from the default
   1.386 +  /// contructed value (i.e. \c %Value()).
   1.387 +  /// This type conforms the \ref concepts::ReferenceMap "ReferenceMap"
   1.388 +  /// concept.
   1.389 +  ///
   1.390 +  /// This map is useful if a default value should be assigned to most of
   1.391 +  /// the keys and different values should be assigned only to a few
   1.392 +  /// keys (i.e. the map is "sparse").
   1.393 +  /// The name of this type also refers to this important usage.
   1.394 +  ///
   1.395 +  /// Apart form that this map can be used in many other cases since it
   1.396 +  /// is based on \c std::map, which is a general associative container.
   1.397 +  /// However keep in mind that it is usually not as efficient as other
   1.398 +  /// maps.
   1.399 +  ///
   1.400 +  /// The simplest way of using this map is through the sparseMap()
   1.401 +  /// function.
   1.402 +  template <typename K, typename V, typename Compare = std::less<K> >
   1.403 +  class SparseMap : public MapBase<K, V> {
   1.404 +    template <typename K1, typename V1, typename C1>
   1.405 +    friend class SparseMap;
   1.406 +  public:
   1.407 +
   1.408 +    typedef MapBase<K, V> Parent;
   1.409 +    /// Key type
   1.410 +    typedef typename Parent::Key Key;
   1.411 +    /// Value type
   1.412 +    typedef typename Parent::Value Value;
   1.413 +    /// Reference type
   1.414 +    typedef Value& Reference;
   1.415 +    /// Const reference type
   1.416 +    typedef const Value& ConstReference;
   1.417  
   1.418      typedef True ReferenceMapTag;
   1.419  
   1.420    private:
   1.421 -    
   1.422 -    typedef std::map<K, T, Compare> Map;
   1.423 +
   1.424 +    typedef std::map<K, V, Compare> Map;
   1.425 +    Map _map;
   1.426      Value _value;
   1.427 -    Map _map;
   1.428  
   1.429    public:
   1.430  
   1.431 -    /// Constructor with specified default value
   1.432 -    StdMap(const T& value = T()) : _value(value) {}
   1.433 -    /// \brief Constructs the map from an appropriate \c std::map, and 
   1.434 +    /// \brief Constructor with specified default value.
   1.435 +    SparseMap(const Value &value = Value()) : _value(value) {}
   1.436 +    /// \brief Constructs the map from an appropriate \c std::map, and
   1.437      /// explicitly specifies a default value.
   1.438 -    template <typename T1, typename Comp1>
   1.439 -    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
   1.440 +    template <typename V1, typename Comp1>
   1.441 +    SparseMap(const std::map<Key, V1, Comp1> &map,
   1.442 +              const Value &value = Value())
   1.443        : _map(map.begin(), map.end()), _value(value) {}
   1.444 -    
   1.445 -    /// \brief Constructs a map from an other \ref StdMap.
   1.446 -    template<typename T1, typename Comp1>
   1.447 -    StdMap(const StdMap<Key, T1, Comp1> &c) 
   1.448 +
   1.449 +    /// \brief Constructs the map from another \ref SparseMap.
   1.450 +    template<typename V1, typename Comp1>
   1.451 +    SparseMap(const SparseMap<Key, V1, Comp1> &c)
   1.452        : _map(c._map.begin(), c._map.end()), _value(c._value) {}
   1.453  
   1.454    private:
   1.455  
   1.456 -    StdMap& operator=(const StdMap&);
   1.457 +    SparseMap& operator=(const SparseMap&);
   1.458  
   1.459    public:
   1.460  
   1.461 @@ -219,7 +404,7 @@
   1.462  	return _map.insert(it, std::make_pair(k, _value))->second;
   1.463      }
   1.464  
   1.465 -    /// \e 
   1.466 +    ///\e
   1.467      ConstReference operator[](const Key &k) const {
   1.468        typename Map::const_iterator it = _map.find(k);
   1.469        if (it != _map.end())
   1.470 @@ -228,149 +413,48 @@
   1.471  	return _value;
   1.472      }
   1.473  
   1.474 -    /// \e 
   1.475 -    void set(const Key &k, const T &t) {
   1.476 +    ///\e
   1.477 +    void set(const Key &k, const Value &v) {
   1.478        typename Map::iterator it = _map.lower_bound(k);
   1.479        if (it != _map.end() && !_map.key_comp()(k, it->first))
   1.480 -	it->second = t;
   1.481 +	it->second = v;
   1.482        else
   1.483 -	_map.insert(it, std::make_pair(k, t));
   1.484 +	_map.insert(it, std::make_pair(k, v));
   1.485      }
   1.486  
   1.487 -    /// \e
   1.488 -    void setAll(const T &t) {
   1.489 -      _value = t;
   1.490 +    ///\e
   1.491 +    void setAll(const Value &v) {
   1.492 +      _value = v;
   1.493        _map.clear();
   1.494 -    }    
   1.495 +    }
   1.496 +  };
   1.497  
   1.498 -  };
   1.499 -  
   1.500 -  ///Returns a \c StdMap class
   1.501 +  /// Returns a \ref SparseMap class
   1.502  
   1.503 -  ///This function just returns a \c StdMap class with specified 
   1.504 -  ///default value.
   1.505 -  ///\relates StdMap
   1.506 -  template<typename K, typename V, typename Compare> 
   1.507 -  inline StdMap<K, V, Compare> stdMap(const V& value = V()) {
   1.508 -    return StdMap<K, V, Compare>(value);
   1.509 -  }
   1.510 -  
   1.511 -  ///Returns a \c StdMap class
   1.512 -
   1.513 -  ///This function just returns a \c StdMap class with specified 
   1.514 -  ///default value.
   1.515 -  ///\relates StdMap
   1.516 -  template<typename K, typename V> 
   1.517 -  inline StdMap<K, V, std::less<K> > stdMap(const V& value = V()) {
   1.518 -    return StdMap<K, V, std::less<K> >(value);
   1.519 -  }
   1.520 -  
   1.521 -  ///Returns a \c StdMap class created from an appropriate std::map
   1.522 -
   1.523 -  ///This function just returns a \c StdMap class created from an 
   1.524 -  ///appropriate std::map.
   1.525 -  ///\relates StdMap
   1.526 -  template<typename K, typename V, typename Compare> 
   1.527 -  inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, 
   1.528 -                                       const V& value = V() ) {
   1.529 -    return StdMap<K, V, Compare>(map, value);
   1.530 +  /// This function just returns a \ref SparseMap class with specified
   1.531 +  /// default value.
   1.532 +  /// \relates SparseMap
   1.533 +  template<typename K, typename V, typename Compare>
   1.534 +  inline SparseMap<K, V, Compare> sparseMap(const V& value = V()) {
   1.535 +    return SparseMap<K, V, Compare>(value);
   1.536    }
   1.537  
   1.538 -  ///Returns a \c StdMap class created from an appropriate std::map
   1.539 -
   1.540 -  ///This function just returns a \c StdMap class created from an 
   1.541 -  ///appropriate std::map.
   1.542 -  ///\relates StdMap
   1.543 -  template<typename K, typename V> 
   1.544 -  inline StdMap<K, V, std::less<K> > stdMap( const std::map<K, V, std::less<K> > &map, 
   1.545 -                                             const V& value = V() ) {
   1.546 -    return StdMap<K, V, std::less<K> >(map, value);
   1.547 +  template<typename K, typename V>
   1.548 +  inline SparseMap<K, V, std::less<K> > sparseMap(const V& value = V()) {
   1.549 +    return SparseMap<K, V, std::less<K> >(value);
   1.550    }
   1.551  
   1.552 -  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
   1.553 -  ///
   1.554 -  /// This map has the <tt>[0..size-1]</tt> keyset and the values
   1.555 -  /// are stored in a \c std::vector<T>  container. It can be used with
   1.556 -  /// some data structures, for example \c UnionFind, \c BinHeap, when 
   1.557 -  /// the used items are small integer numbers.
   1.558 -  /// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
   1.559 -  ///
   1.560 -  /// \todo Revise its name
   1.561 -  template <typename T>
   1.562 -  class IntegerMap : public MapBase<int, T> {
   1.563 +  /// \brief Returns a \ref SparseMap class created from an appropriate
   1.564 +  /// \c std::map
   1.565  
   1.566 -    template <typename T1>
   1.567 -    friend class IntegerMap;
   1.568 -
   1.569 -  public:
   1.570 -
   1.571 -    typedef MapBase<int, T> Parent;
   1.572 -    ///\e
   1.573 -    typedef typename Parent::Key Key;
   1.574 -    ///\e
   1.575 -    typedef typename Parent::Value Value;
   1.576 -    ///\e
   1.577 -    typedef T& Reference;
   1.578 -    ///\e
   1.579 -    typedef const T& ConstReference;
   1.580 -
   1.581 -    typedef True ReferenceMapTag;
   1.582 -
   1.583 -  private:
   1.584 -    
   1.585 -    typedef std::vector<T> Vector;
   1.586 -    Vector _vector;
   1.587 -
   1.588 -  public:
   1.589 -
   1.590 -    /// Constructor with specified default value
   1.591 -    IntegerMap(int size = 0, const T& value = T()) : _vector(size, value) {}
   1.592 -
   1.593 -    /// \brief Constructs the map from an appropriate \c std::vector.
   1.594 -    template <typename T1>
   1.595 -    IntegerMap(const std::vector<T1>& vector) 
   1.596 -      : _vector(vector.begin(), vector.end()) {}
   1.597 -    
   1.598 -    /// \brief Constructs a map from an other \ref IntegerMap.
   1.599 -    template <typename T1>
   1.600 -    IntegerMap(const IntegerMap<T1> &c) 
   1.601 -      : _vector(c._vector.begin(), c._vector.end()) {}
   1.602 -
   1.603 -    /// \brief Resize the container
   1.604 -    void resize(int size, const T& value = T()) {
   1.605 -      _vector.resize(size, value);
   1.606 -    }
   1.607 -
   1.608 -  private:
   1.609 -
   1.610 -    IntegerMap& operator=(const IntegerMap&);
   1.611 -
   1.612 -  public:
   1.613 -
   1.614 -    ///\e
   1.615 -    Reference operator[](Key k) {
   1.616 -      return _vector[k];
   1.617 -    }
   1.618 -
   1.619 -    /// \e 
   1.620 -    ConstReference operator[](Key k) const {
   1.621 -      return _vector[k];
   1.622 -    }
   1.623 -
   1.624 -    /// \e 
   1.625 -    void set(const Key &k, const T& t) {
   1.626 -      _vector[k] = t;
   1.627 -    }
   1.628 -
   1.629 -  };
   1.630 -  
   1.631 -  ///Returns an \c IntegerMap class
   1.632 -
   1.633 -  ///This function just returns an \c IntegerMap class.
   1.634 -  ///\relates IntegerMap
   1.635 -  template<typename T>
   1.636 -  inline IntegerMap<T> integerMap(int size = 0, const T& value = T()) {
   1.637 -    return IntegerMap<T>(size, value);
   1.638 +  /// This function just returns a \ref SparseMap class created from an
   1.639 +  /// appropriate \c std::map.
   1.640 +  /// \relates SparseMap
   1.641 +  template<typename K, typename V, typename Compare>
   1.642 +  inline SparseMap<K, V, Compare>
   1.643 +    sparseMap(const std::map<K, V, Compare> &map, const V& value = V())
   1.644 +  {
   1.645 +    return SparseMap<K, V, Compare>(map, value);
   1.646    }
   1.647  
   1.648    /// @}
   1.649 @@ -378,886 +462,1008 @@
   1.650    /// \addtogroup map_adaptors
   1.651    /// @{
   1.652  
   1.653 -  /// \brief Identity map.
   1.654 +  /// Composition of two maps
   1.655 +
   1.656 +  /// This \ref concepts::ReadMap "read only map" returns the
   1.657 +  /// composition of two given maps. That is to say, if \c m1 is of
   1.658 +  /// type \c M1 and \c m2 is of \c M2, then for
   1.659 +  /// \code
   1.660 +  ///   ComposeMap<M1, M2> cm(m1,m2);
   1.661 +  /// \endcode
   1.662 +  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
   1.663    ///
   1.664 -  /// This map gives back the given key as value without any
   1.665 -  /// modification. 
   1.666 -  template <typename T>
   1.667 -  class IdentityMap : public MapBase<T, T> {
   1.668 +  /// The \c Key type of the map is inherited from \c M2 and the
   1.669 +  /// \c Value type is from \c M1.
   1.670 +  /// \c M2::Value must be convertible to \c M1::Key.
   1.671 +  ///
   1.672 +  /// The simplest way of using this map is through the composeMap()
   1.673 +  /// function.
   1.674 +  ///
   1.675 +  /// \sa CombineMap
   1.676 +  ///
   1.677 +  /// \todo Check the requirements.
   1.678 +  template <typename M1, typename M2>
   1.679 +  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
   1.680 +    const M1 &_m1;
   1.681 +    const M2 &_m2;
   1.682    public:
   1.683 -    typedef MapBase<T, T> Parent;
   1.684 +    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
   1.685      typedef typename Parent::Key Key;
   1.686      typedef typename Parent::Value Value;
   1.687  
   1.688 +    /// Constructor
   1.689 +    ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
   1.690 +
   1.691      /// \e
   1.692 -    const T& operator[](const T& t) const {
   1.693 -      return t;
   1.694 -    }
   1.695 +    typename MapTraits<M1>::ConstReturnValue
   1.696 +    operator[](const Key &k) const { return _m1[_m2[k]]; }
   1.697    };
   1.698  
   1.699 -  ///Returns an \c IdentityMap class
   1.700 +  /// Returns a \ref ComposeMap class
   1.701  
   1.702 -  ///This function just returns an \c IdentityMap class.
   1.703 -  ///\relates IdentityMap
   1.704 -  template<typename T>
   1.705 -  inline IdentityMap<T> identityMap() {
   1.706 -    return IdentityMap<T>();
   1.707 +  /// This function just returns a \ref ComposeMap class.
   1.708 +  ///
   1.709 +  /// If \c m1 and \c m2 are maps and the \c Value type of \c m2 is
   1.710 +  /// convertible to the \c Key of \c m1, then <tt>composeMap(m1,m2)[x]</tt>
   1.711 +  /// will be equal to <tt>m1[m2[x]]</tt>.
   1.712 +  ///
   1.713 +  /// \relates ComposeMap
   1.714 +  template <typename M1, typename M2>
   1.715 +  inline ComposeMap<M1, M2> composeMap(const M1 &m1, const M2 &m2) {
   1.716 +    return ComposeMap<M1, M2>(m1, m2);
   1.717    }
   1.718 -  
   1.719  
   1.720 -  ///\brief Convert the \c Value of a map to another type using
   1.721 -  ///the default conversion.
   1.722 +
   1.723 +  /// Combination of two maps using an STL (binary) functor.
   1.724 +
   1.725 +  /// This \ref concepts::ReadMap "read only map" takes two maps and a
   1.726 +  /// binary functor and returns the combination of the two given maps
   1.727 +  /// using the functor.
   1.728 +  /// That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2
   1.729 +  /// and \c f is of \c F, then for
   1.730 +  /// \code
   1.731 +  ///   CombineMap<M1,M2,F,V> cm(m1,m2,f);
   1.732 +  /// \endcode
   1.733 +  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>.
   1.734    ///
   1.735 -  ///This \ref concepts::ReadMap "read only map"
   1.736 -  ///converts the \c Value of a map to type \c T.
   1.737 -  ///Its \c Key is inherited from \c M.
   1.738 -  template <typename M, typename T> 
   1.739 -  class ConvertMap : public MapBase<typename M::Key, T> {
   1.740 -    const M& m;
   1.741 +  /// The \c Key type of the map is inherited from \c M1 (\c M1::Key
   1.742 +  /// must be convertible to \c M2::Key) and the \c Value type is \c V.
   1.743 +  /// \c M2::Value and \c M1::Value must be convertible to the
   1.744 +  /// corresponding input parameter of \c F and the return type of \c F
   1.745 +  /// must be convertible to \c V.
   1.746 +  ///
   1.747 +  /// The simplest way of using this map is through the combineMap()
   1.748 +  /// function.
   1.749 +  ///
   1.750 +  /// \sa ComposeMap
   1.751 +  ///
   1.752 +  /// \todo Check the requirements.
   1.753 +  template<typename M1, typename M2, typename F,
   1.754 +	   typename V = typename F::result_type>
   1.755 +  class CombineMap : public MapBase<typename M1::Key, V> {
   1.756 +    const M1 &_m1;
   1.757 +    const M2 &_m2;
   1.758 +    F _f;
   1.759    public:
   1.760 -    typedef MapBase<typename M::Key, T> Parent;
   1.761 +    typedef MapBase<typename M1::Key, V> Parent;
   1.762      typedef typename Parent::Key Key;
   1.763      typedef typename Parent::Value Value;
   1.764  
   1.765 -    ///Constructor
   1.766 +    /// Constructor
   1.767 +    CombineMap(const M1 &m1, const M2 &m2, const F &f = F())
   1.768 +      : _m1(m1), _m2(m2), _f(f) {}
   1.769 +    /// \e
   1.770 +    Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); }
   1.771 +  };
   1.772  
   1.773 -    ///Constructor.
   1.774 -    ///\param _m is the underlying map.
   1.775 -    ConvertMap(const M &_m) : m(_m) {};
   1.776 +  /// Returns a \ref CombineMap class
   1.777  
   1.778 -    ///\e
   1.779 -    Value operator[](const Key& k) const {return m[k];}
   1.780 -  };
   1.781 -  
   1.782 -  ///Returns a \c ConvertMap class
   1.783 -
   1.784 -  ///This function just returns a \c ConvertMap class.
   1.785 -  ///\relates ConvertMap
   1.786 -  template<typename T, typename M>
   1.787 -  inline ConvertMap<M, T> convertMap(const M &m) {
   1.788 -    return ConvertMap<M, T>(m);
   1.789 +  /// This function just returns a \ref CombineMap class.
   1.790 +  ///
   1.791 +  /// For example, if \c m1 and \c m2 are both maps with \c double
   1.792 +  /// values, then
   1.793 +  /// \code
   1.794 +  ///   combineMap(m1,m2,std::plus<double>())
   1.795 +  /// \endcode
   1.796 +  /// is equivalent to
   1.797 +  /// \code
   1.798 +  ///   addMap(m1,m2)
   1.799 +  /// \endcode
   1.800 +  ///
   1.801 +  /// This function is specialized for adaptable binary function
   1.802 +  /// classes and C++ functions.
   1.803 +  ///
   1.804 +  /// \relates CombineMap
   1.805 +  template<typename M1, typename M2, typename F, typename V>
   1.806 +  inline CombineMap<M1, M2, F, V>
   1.807 +  combineMap(const M1 &m1, const M2 &m2, const F &f) {
   1.808 +    return CombineMap<M1, M2, F, V>(m1,m2,f);
   1.809    }
   1.810  
   1.811 -  ///Simple wrapping of a map
   1.812 +  template<typename M1, typename M2, typename F>
   1.813 +  inline CombineMap<M1, M2, F, typename F::result_type>
   1.814 +  combineMap(const M1 &m1, const M2 &m2, const F &f) {
   1.815 +    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
   1.816 +  }
   1.817  
   1.818 -  ///This \ref concepts::ReadMap "read only map" returns the simple
   1.819 -  ///wrapping of the given map. Sometimes the reference maps cannot be
   1.820 -  ///combined with simple read maps. This map adaptor wraps the given
   1.821 -  ///map to simple read map.
   1.822 +  template<typename M1, typename M2, typename K1, typename K2, typename V>
   1.823 +  inline CombineMap<M1, M2, V (*)(K1, K2), V>
   1.824 +  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
   1.825 +    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
   1.826 +  }
   1.827 +
   1.828 +
   1.829 +  /// Converts an STL style (unary) functor to a map
   1.830 +
   1.831 +  /// This \ref concepts::ReadMap "read only map" returns the value
   1.832 +  /// of a given functor. Actually, it just wraps the functor and
   1.833 +  /// provides the \c Key and \c Value typedefs.
   1.834    ///
   1.835 -  ///\sa SimpleWriteMap
   1.836 +  /// Template parameters \c K and \c V will become its \c Key and
   1.837 +  /// \c Value. In most cases they have to be given explicitly because
   1.838 +  /// a functor typically does not provide \c argument_type and
   1.839 +  /// \c result_type typedefs.
   1.840 +  /// Parameter \c F is the type of the used functor.
   1.841    ///
   1.842 -  /// \todo Revise the misleading name 
   1.843 -  template<typename M> 
   1.844 -  class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
   1.845 -    const M& m;
   1.846 +  /// The simplest way of using this map is through the functorToMap()
   1.847 +  /// function.
   1.848 +  ///
   1.849 +  /// \sa MapToFunctor
   1.850 +  template<typename F,
   1.851 +	   typename K = typename F::argument_type,
   1.852 +	   typename V = typename F::result_type>
   1.853 +  class FunctorToMap : public MapBase<K, V> {
   1.854 +    const F &_f;
   1.855 +  public:
   1.856 +    typedef MapBase<K, V> Parent;
   1.857 +    typedef typename Parent::Key Key;
   1.858 +    typedef typename Parent::Value Value;
   1.859  
   1.860 +    /// Constructor
   1.861 +    FunctorToMap(const F &f = F()) : _f(f) {}
   1.862 +    /// \e
   1.863 +    Value operator[](const Key &k) const { return _f(k); }
   1.864 +  };
   1.865 +
   1.866 +  /// Returns a \ref FunctorToMap class
   1.867 +
   1.868 +  /// This function just returns a \ref FunctorToMap class.
   1.869 +  ///
   1.870 +  /// This function is specialized for adaptable binary function
   1.871 +  /// classes and C++ functions.
   1.872 +  ///
   1.873 +  /// \relates FunctorToMap
   1.874 +  template<typename K, typename V, typename F>
   1.875 +  inline FunctorToMap<F, K, V> functorToMap(const F &f) {
   1.876 +    return FunctorToMap<F, K, V>(f);
   1.877 +  }
   1.878 +
   1.879 +  template <typename F>
   1.880 +  inline FunctorToMap<F, typename F::argument_type, typename F::result_type>
   1.881 +    functorToMap(const F &f)
   1.882 +  {
   1.883 +    return FunctorToMap<F, typename F::argument_type,
   1.884 +      typename F::result_type>(f);
   1.885 +  }
   1.886 +
   1.887 +  template <typename K, typename V>
   1.888 +  inline FunctorToMap<V (*)(K), K, V> functorToMap(V (*f)(K)) {
   1.889 +    return FunctorToMap<V (*)(K), K, V>(f);
   1.890 +  }
   1.891 +
   1.892 +
   1.893 +  /// Converts a map to an STL style (unary) functor
   1.894 +
   1.895 +  /// This class converts a map to an STL style (unary) functor.
   1.896 +  /// That is it provides an <tt>operator()</tt> to read its values.
   1.897 +  ///
   1.898 +  /// For the sake of convenience it also works as a usual
   1.899 +  /// \ref concepts::ReadMap "readable map", i.e. <tt>operator[]</tt>
   1.900 +  /// and the \c Key and \c Value typedefs also exist.
   1.901 +  ///
   1.902 +  /// The simplest way of using this map is through the mapToFunctor()
   1.903 +  /// function.
   1.904 +  ///
   1.905 +  ///\sa FunctorToMap
   1.906 +  template <typename M>
   1.907 +  class MapToFunctor : public MapBase<typename M::Key, typename M::Value> {
   1.908 +    const M &_m;
   1.909    public:
   1.910      typedef MapBase<typename M::Key, typename M::Value> Parent;
   1.911      typedef typename Parent::Key Key;
   1.912      typedef typename Parent::Value Value;
   1.913  
   1.914 -    ///Constructor
   1.915 -    SimpleMap(const M &_m) : m(_m) {};
   1.916 -    ///\e
   1.917 -    Value operator[](Key k) const {return m[k];}
   1.918 +    typedef typename Parent::Key argument_type;
   1.919 +    typedef typename Parent::Value result_type;
   1.920 +
   1.921 +    /// Constructor
   1.922 +    MapToFunctor(const M &m) : _m(m) {}
   1.923 +    /// \e
   1.924 +    Value operator()(const Key &k) const { return _m[k]; }
   1.925 +    /// \e
   1.926 +    Value operator[](const Key &k) const { return _m[k]; }
   1.927    };
   1.928 -  
   1.929 -  ///Returns a \c SimpleMap class
   1.930  
   1.931 -  ///This function just returns a \c SimpleMap class.
   1.932 -  ///\relates SimpleMap
   1.933 +  /// Returns a \ref MapToFunctor class
   1.934 +
   1.935 +  /// This function just returns a \ref MapToFunctor class.
   1.936 +  /// \relates MapToFunctor
   1.937    template<typename M>
   1.938 -  inline SimpleMap<M> simpleMap(const M &m) {
   1.939 -    return SimpleMap<M>(m);
   1.940 +  inline MapToFunctor<M> mapToFunctor(const M &m) {
   1.941 +    return MapToFunctor<M>(m);
   1.942    }
   1.943  
   1.944 -  ///Simple writable wrapping of a map
   1.945  
   1.946 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the simple
   1.947 -  ///wrapping of the given map. Sometimes the reference maps cannot be
   1.948 -  ///combined with simple read-write maps. This map adaptor wraps the
   1.949 -  ///given map to simple read-write map.
   1.950 +  /// \brief Map adaptor to convert the \c Value type of a map to
   1.951 +  /// another type using the default conversion.
   1.952 +
   1.953 +  /// Map adaptor to convert the \c Value type of a \ref concepts::ReadMap
   1.954 +  /// "readable map" to another type using the default conversion.
   1.955 +  /// The \c Key type of it is inherited from \c M and the \c Value
   1.956 +  /// type is \c V.
   1.957 +  /// This type conforms the \ref concepts::ReadMap "ReadMap" concept.
   1.958    ///
   1.959 -  ///\sa SimpleMap
   1.960 +  /// The simplest way of using this map is through the convertMap()
   1.961 +  /// function.
   1.962 +  template <typename M, typename V>
   1.963 +  class ConvertMap : public MapBase<typename M::Key, V> {
   1.964 +    const M &_m;
   1.965 +  public:
   1.966 +    typedef MapBase<typename M::Key, V> Parent;
   1.967 +    typedef typename Parent::Key Key;
   1.968 +    typedef typename Parent::Value Value;
   1.969 +
   1.970 +    /// Constructor
   1.971 +
   1.972 +    /// Constructor.
   1.973 +    /// \param m The underlying map.
   1.974 +    ConvertMap(const M &m) : _m(m) {}
   1.975 +
   1.976 +    /// \e
   1.977 +    Value operator[](const Key &k) const { return _m[k]; }
   1.978 +  };
   1.979 +
   1.980 +  /// Returns a \ref ConvertMap class
   1.981 +
   1.982 +  /// This function just returns a \ref ConvertMap class.
   1.983 +  /// \relates ConvertMap
   1.984 +  template<typename V, typename M>
   1.985 +  inline ConvertMap<M, V> convertMap(const M &map) {
   1.986 +    return ConvertMap<M, V>(map);
   1.987 +  }
   1.988 +
   1.989 +
   1.990 +  /// Applies all map setting operations to two maps
   1.991 +
   1.992 +  /// This map has two \ref concepts::WriteMap "writable map" parameters
   1.993 +  /// and each write request will be passed to both of them.
   1.994 +  /// If \c M1 is also \ref concepts::ReadMap "readable", then the read
   1.995 +  /// operations will return the corresponding values of \c M1.
   1.996    ///
   1.997 -  /// \todo Revise the misleading name
   1.998 -  template<typename M> 
   1.999 -  class SimpleWriteMap : public MapBase<typename M::Key, typename M::Value> {
  1.1000 -    M& m;
  1.1001 +  /// The \c Key and \c Value types are inherited from \c M1.
  1.1002 +  /// The \c Key and \c Value of \c M2 must be convertible from those
  1.1003 +  /// of \c M1.
  1.1004 +  ///
  1.1005 +  /// The simplest way of using this map is through the forkMap()
  1.1006 +  /// function.
  1.1007 +  template<typename  M1, typename M2>
  1.1008 +  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1009 +    M1 &_m1;
  1.1010 +    M2 &_m2;
  1.1011 +  public:
  1.1012 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1013 +    typedef typename Parent::Key Key;
  1.1014 +    typedef typename Parent::Value Value;
  1.1015  
  1.1016 +    /// Constructor
  1.1017 +    ForkMap(M1 &m1, M2 &m2) : _m1(m1), _m2(m2) {}
  1.1018 +    /// Returns the value associated with the given key in the first map.
  1.1019 +    Value operator[](const Key &k) const { return _m1[k]; }
  1.1020 +    /// Sets the value associated with the given key in both maps.
  1.1021 +    void set(const Key &k, const Value &v) { _m1.set(k,v); _m2.set(k,v); }
  1.1022 +  };
  1.1023 +
  1.1024 +  /// Returns a \ref ForkMap class
  1.1025 +
  1.1026 +  /// This function just returns a \ref ForkMap class.
  1.1027 +  /// \relates ForkMap
  1.1028 +  template <typename M1, typename M2>
  1.1029 +  inline ForkMap<M1,M2> forkMap(M1 &m1, M2 &m2) {
  1.1030 +    return ForkMap<M1,M2>(m1,m2);
  1.1031 +  }
  1.1032 +
  1.1033 +
  1.1034 +  /// Simple wrapping of a map
  1.1035 +
  1.1036 +  /// This \ref concepts::ReadMap "read only map" returns the simple
  1.1037 +  /// wrapping of the given map. Sometimes the reference maps cannot be
  1.1038 +  /// combined with simple read maps. This map adaptor wraps the given
  1.1039 +  /// map to simple read map.
  1.1040 +  ///
  1.1041 +  /// The simplest way of using this map is through the wrapMap()
  1.1042 +  /// function.
  1.1043 +  ///
  1.1044 +  /// \sa WrapWriteMap
  1.1045 +  template<typename M>
  1.1046 +  class WrapMap : public MapBase<typename M::Key, typename M::Value> {
  1.1047 +    const M &_m;
  1.1048    public:
  1.1049      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1050      typedef typename Parent::Key Key;
  1.1051      typedef typename Parent::Value Value;
  1.1052  
  1.1053 -    ///Constructor
  1.1054 -    SimpleWriteMap(M &_m) : m(_m) {};
  1.1055 -    ///\e
  1.1056 -    Value operator[](Key k) const {return m[k];}
  1.1057 -    ///\e
  1.1058 -    void set(Key k, const Value& c) { m.set(k, c); }
  1.1059 +    /// Constructor
  1.1060 +    WrapMap(const M &m) : _m(m) {}
  1.1061 +    /// \e
  1.1062 +    Value operator[](const Key &k) const { return _m[k]; }
  1.1063    };
  1.1064  
  1.1065 -  ///Returns a \c SimpleWriteMap class
  1.1066 +  /// Returns a \ref WrapMap class
  1.1067  
  1.1068 -  ///This function just returns a \c SimpleWriteMap class.
  1.1069 -  ///\relates SimpleWriteMap
  1.1070 +  /// This function just returns a \ref WrapMap class.
  1.1071 +  /// \relates WrapMap
  1.1072    template<typename M>
  1.1073 -  inline SimpleWriteMap<M> simpleWriteMap(M &m) {
  1.1074 -    return SimpleWriteMap<M>(m);
  1.1075 +  inline WrapMap<M> wrapMap(const M &map) {
  1.1076 +    return WrapMap<M>(map);
  1.1077    }
  1.1078  
  1.1079 -  ///Sum of two maps
  1.1080  
  1.1081 -  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
  1.1082 -  ///given maps.
  1.1083 -  ///Its \c Key and \c Value are inherited from \c M1.
  1.1084 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  1.1085 -  template<typename M1, typename M2> 
  1.1086 +  /// Simple writable wrapping of a map
  1.1087 +
  1.1088 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the simple
  1.1089 +  /// wrapping of the given map. Sometimes the reference maps cannot be
  1.1090 +  /// combined with simple read-write maps. This map adaptor wraps the
  1.1091 +  /// given map to simple read-write map.
  1.1092 +  ///
  1.1093 +  /// The simplest way of using this map is through the wrapWriteMap()
  1.1094 +  /// function.
  1.1095 +  ///
  1.1096 +  /// \sa WrapMap
  1.1097 +  template<typename M>
  1.1098 +  class WrapWriteMap : public MapBase<typename M::Key, typename M::Value> {
  1.1099 +    M &_m;
  1.1100 +  public:
  1.1101 +    typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1102 +    typedef typename Parent::Key Key;
  1.1103 +    typedef typename Parent::Value Value;
  1.1104 +
  1.1105 +    /// Constructor
  1.1106 +    WrapWriteMap(M &m) : _m(m) {}
  1.1107 +    /// \e
  1.1108 +    Value operator[](const Key &k) const { return _m[k]; }
  1.1109 +    /// \e
  1.1110 +    void set(const Key &k, const Value &c) { _m.set(k, c); }
  1.1111 +  };
  1.1112 +
  1.1113 +  ///Returns a \ref WrapWriteMap class
  1.1114 +
  1.1115 +  ///This function just returns a \ref WrapWriteMap class.
  1.1116 +  ///\relates WrapWriteMap
  1.1117 +  template<typename M>
  1.1118 +  inline WrapWriteMap<M> wrapWriteMap(M &map) {
  1.1119 +    return WrapWriteMap<M>(map);
  1.1120 +  }
  1.1121 +
  1.1122 +
  1.1123 +  /// Sum of two maps
  1.1124 +
  1.1125 +  /// This \ref concepts::ReadMap "read only map" returns the sum
  1.1126 +  /// of the values of the two given maps.
  1.1127 +  /// Its \c Key and \c Value types are inherited from \c M1.
  1.1128 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  1.1129 +  /// \c M1.
  1.1130 +  ///
  1.1131 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  1.1132 +  /// \code
  1.1133 +  ///   AddMap<M1,M2> am(m1,m2);
  1.1134 +  /// \endcode
  1.1135 +  /// <tt>am[x]</tt> will be equal to <tt>m1[x]+m2[x]</tt>.
  1.1136 +  ///
  1.1137 +  /// The simplest way of using this map is through the addMap()
  1.1138 +  /// function.
  1.1139 +  ///
  1.1140 +  /// \sa SubMap, MulMap, DivMap
  1.1141 +  /// \sa ShiftMap, ShiftWriteMap
  1.1142 +  template<typename M1, typename M2>
  1.1143    class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1144 -    const M1& m1;
  1.1145 -    const M2& m2;
  1.1146 -
  1.1147 +    const M1 &_m1;
  1.1148 +    const M2 &_m2;
  1.1149    public:
  1.1150      typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1151      typedef typename Parent::Key Key;
  1.1152      typedef typename Parent::Value Value;
  1.1153  
  1.1154 -    ///Constructor
  1.1155 -    AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  1.1156 -    ///\e
  1.1157 -    Value operator[](Key k) const {return m1[k]+m2[k];}
  1.1158 +    /// Constructor
  1.1159 +    AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  1.1160 +    /// \e
  1.1161 +    Value operator[](const Key &k) const { return _m1[k]+_m2[k]; }
  1.1162    };
  1.1163 -  
  1.1164 -  ///Returns an \c AddMap class
  1.1165  
  1.1166 -  ///This function just returns an \c AddMap class.
  1.1167 -  ///\todo Extend the documentation: how to call these type of functions?
  1.1168 +  /// Returns an \ref AddMap class
  1.1169 +
  1.1170 +  /// This function just returns an \ref AddMap class.
  1.1171    ///
  1.1172 -  ///\relates AddMap
  1.1173 -  template<typename M1, typename M2> 
  1.1174 -  inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
  1.1175 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  1.1176 +  /// values, then <tt>addMap(m1,m2)[x]</tt> will be equal to
  1.1177 +  /// <tt>m1[x]+m2[x]</tt>.
  1.1178 +  ///
  1.1179 +  /// \relates AddMap
  1.1180 +  template<typename M1, typename M2>
  1.1181 +  inline AddMap<M1, M2> addMap(const M1 &m1, const M2 &m2) {
  1.1182      return AddMap<M1, M2>(m1,m2);
  1.1183    }
  1.1184  
  1.1185 -  ///Shift a map with a constant.
  1.1186  
  1.1187 -  ///This \ref concepts::ReadMap "read only map" returns the sum of the
  1.1188 -  ///given map and a constant value.
  1.1189 -  ///Its \c Key and \c Value are inherited from \c M.
  1.1190 +  /// Difference of two maps
  1.1191 +
  1.1192 +  /// This \ref concepts::ReadMap "read only map" returns the difference
  1.1193 +  /// of the values of the two given maps.
  1.1194 +  /// Its \c Key and \c Value types are inherited from \c M1.
  1.1195 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  1.1196 +  /// \c M1.
  1.1197    ///
  1.1198 -  ///Actually,
  1.1199 -  ///\code
  1.1200 -  ///  ShiftMap<X> sh(x,v);
  1.1201 -  ///\endcode
  1.1202 -  ///is equivalent to
  1.1203 -  ///\code
  1.1204 -  ///  ConstMap<X::Key, X::Value> c_tmp(v);
  1.1205 -  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
  1.1206 -  ///\endcode
  1.1207 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  1.1208 +  /// \code
  1.1209 +  ///   SubMap<M1,M2> sm(m1,m2);
  1.1210 +  /// \endcode
  1.1211 +  /// <tt>sm[x]</tt> will be equal to <tt>m1[x]-m2[x]</tt>.
  1.1212    ///
  1.1213 -  ///\sa ShiftWriteMap
  1.1214 -  template<typename M, typename C = typename M::Value> 
  1.1215 +  /// The simplest way of using this map is through the subMap()
  1.1216 +  /// function.
  1.1217 +  ///
  1.1218 +  /// \sa AddMap, MulMap, DivMap
  1.1219 +  template<typename M1, typename M2>
  1.1220 +  class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1221 +    const M1 &_m1;
  1.1222 +    const M2 &_m2;
  1.1223 +  public:
  1.1224 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1225 +    typedef typename Parent::Key Key;
  1.1226 +    typedef typename Parent::Value Value;
  1.1227 +
  1.1228 +    /// Constructor
  1.1229 +    SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  1.1230 +    /// \e
  1.1231 +    Value operator[](const Key &k) const { return _m1[k]-_m2[k]; }
  1.1232 +  };
  1.1233 +
  1.1234 +  /// Returns a \ref SubMap class
  1.1235 +
  1.1236 +  /// This function just returns a \ref SubMap class.
  1.1237 +  ///
  1.1238 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  1.1239 +  /// values, then <tt>subMap(m1,m2)[x]</tt> will be equal to
  1.1240 +  /// <tt>m1[x]-m2[x]</tt>.
  1.1241 +  ///
  1.1242 +  /// \relates SubMap
  1.1243 +  template<typename M1, typename M2>
  1.1244 +  inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
  1.1245 +    return SubMap<M1, M2>(m1,m2);
  1.1246 +  }
  1.1247 +
  1.1248 +
  1.1249 +  /// Product of two maps
  1.1250 +
  1.1251 +  /// This \ref concepts::ReadMap "read only map" returns the product
  1.1252 +  /// of the values of the two given maps.
  1.1253 +  /// Its \c Key and \c Value types are inherited from \c M1.
  1.1254 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  1.1255 +  /// \c M1.
  1.1256 +  ///
  1.1257 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  1.1258 +  /// \code
  1.1259 +  ///   MulMap<M1,M2> mm(m1,m2);
  1.1260 +  /// \endcode
  1.1261 +  /// <tt>mm[x]</tt> will be equal to <tt>m1[x]*m2[x]</tt>.
  1.1262 +  ///
  1.1263 +  /// The simplest way of using this map is through the mulMap()
  1.1264 +  /// function.
  1.1265 +  ///
  1.1266 +  /// \sa AddMap, SubMap, DivMap
  1.1267 +  /// \sa ScaleMap, ScaleWriteMap
  1.1268 +  template<typename M1, typename M2>
  1.1269 +  class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1270 +    const M1 &_m1;
  1.1271 +    const M2 &_m2;
  1.1272 +  public:
  1.1273 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1274 +    typedef typename Parent::Key Key;
  1.1275 +    typedef typename Parent::Value Value;
  1.1276 +
  1.1277 +    /// Constructor
  1.1278 +    MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
  1.1279 +    /// \e
  1.1280 +    Value operator[](const Key &k) const { return _m1[k]*_m2[k]; }
  1.1281 +  };
  1.1282 +
  1.1283 +  /// Returns a \ref MulMap class
  1.1284 +
  1.1285 +  /// This function just returns a \ref MulMap class.
  1.1286 +  ///
  1.1287 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  1.1288 +  /// values, then <tt>mulMap(m1,m2)[x]</tt> will be equal to
  1.1289 +  /// <tt>m1[x]*m2[x]</tt>.
  1.1290 +  ///
  1.1291 +  /// \relates MulMap
  1.1292 +  template<typename M1, typename M2>
  1.1293 +  inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
  1.1294 +    return MulMap<M1, M2>(m1,m2);
  1.1295 +  }
  1.1296 +
  1.1297 +
  1.1298 +  /// Quotient of two maps
  1.1299 +
  1.1300 +  /// This \ref concepts::ReadMap "read only map" returns the quotient
  1.1301 +  /// of the values of the two given maps.
  1.1302 +  /// Its \c Key and \c Value types are inherited from \c M1.
  1.1303 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  1.1304 +  /// \c M1.
  1.1305 +  ///
  1.1306 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  1.1307 +  /// \code
  1.1308 +  ///   DivMap<M1,M2> dm(m1,m2);
  1.1309 +  /// \endcode
  1.1310 +  /// <tt>dm[x]</tt> will be equal to <tt>m1[x]/m2[x]</tt>.
  1.1311 +  ///
  1.1312 +  /// The simplest way of using this map is through the divMap()
  1.1313 +  /// function.
  1.1314 +  ///
  1.1315 +  /// \sa AddMap, SubMap, MulMap
  1.1316 +  template<typename M1, typename M2>
  1.1317 +  class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1318 +    const M1 &_m1;
  1.1319 +    const M2 &_m2;
  1.1320 +  public:
  1.1321 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1322 +    typedef typename Parent::Key Key;
  1.1323 +    typedef typename Parent::Value Value;
  1.1324 +
  1.1325 +    /// Constructor
  1.1326 +    DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
  1.1327 +    /// \e
  1.1328 +    Value operator[](const Key &k) const { return _m1[k]/_m2[k]; }
  1.1329 +  };
  1.1330 +
  1.1331 +  /// Returns a \ref DivMap class
  1.1332 +
  1.1333 +  /// This function just returns a \ref DivMap class.
  1.1334 +  ///
  1.1335 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  1.1336 +  /// values, then <tt>divMap(m1,m2)[x]</tt> will be equal to
  1.1337 +  /// <tt>m1[x]/m2[x]</tt>.
  1.1338 +  ///
  1.1339 +  /// \relates DivMap
  1.1340 +  template<typename M1, typename M2>
  1.1341 +  inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
  1.1342 +    return DivMap<M1, M2>(m1,m2);
  1.1343 +  }
  1.1344 +
  1.1345 +
  1.1346 +  /// Shifts a map with a constant.
  1.1347 +
  1.1348 +  /// This \ref concepts::ReadMap "read only map" returns the sum of
  1.1349 +  /// the given map and a constant value (i.e. it shifts the map with
  1.1350 +  /// the constant). Its \c Key and \c Value are inherited from \c M.
  1.1351 +  ///
  1.1352 +  /// Actually,
  1.1353 +  /// \code
  1.1354 +  ///   ShiftMap<M> sh(m,v);
  1.1355 +  /// \endcode
  1.1356 +  /// is equivalent to
  1.1357 +  /// \code
  1.1358 +  ///   ConstMap<M::Key, M::Value> cm(v);
  1.1359 +  ///   AddMap<M, ConstMap<M::Key, M::Value> > sh(m,cm);
  1.1360 +  /// \endcode
  1.1361 +  ///
  1.1362 +  /// The simplest way of using this map is through the shiftMap()
  1.1363 +  /// function.
  1.1364 +  ///
  1.1365 +  /// \sa ShiftWriteMap
  1.1366 +  template<typename M, typename C = typename M::Value>
  1.1367    class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
  1.1368 -    const M& m;
  1.1369 -    C v;
  1.1370 +    const M &_m;
  1.1371 +    C _v;
  1.1372    public:
  1.1373      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1374      typedef typename Parent::Key Key;
  1.1375      typedef typename Parent::Value Value;
  1.1376  
  1.1377 -    ///Constructor
  1.1378 +    /// Constructor
  1.1379  
  1.1380 -    ///Constructor.
  1.1381 -    ///\param _m is the undelying map.
  1.1382 -    ///\param _v is the shift value.
  1.1383 -    ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
  1.1384 -    ///\e
  1.1385 -    Value operator[](Key k) const {return m[k] + v;}
  1.1386 +    /// Constructor.
  1.1387 +    /// \param m The undelying map.
  1.1388 +    /// \param v The constant value.
  1.1389 +    ShiftMap(const M &m, const C &v) : _m(m), _v(v) {}
  1.1390 +    /// \e
  1.1391 +    Value operator[](const Key &k) const { return _m[k]+_v; }
  1.1392    };
  1.1393  
  1.1394 -  ///Shift a map with a constant (ReadWrite version).
  1.1395 +  /// Shifts a map with a constant (read-write version).
  1.1396  
  1.1397 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
  1.1398 -  ///given map and a constant value. It makes also possible to write the map.
  1.1399 -  ///Its \c Key and \c Value are inherited from \c M.
  1.1400 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the sum
  1.1401 +  /// of the given map and a constant value (i.e. it shifts the map with
  1.1402 +  /// the constant). Its \c Key and \c Value are inherited from \c M.
  1.1403 +  /// It makes also possible to write the map.
  1.1404    ///
  1.1405 -  ///\sa ShiftMap
  1.1406 -  template<typename M, typename C = typename M::Value> 
  1.1407 +  /// The simplest way of using this map is through the shiftWriteMap()
  1.1408 +  /// function.
  1.1409 +  ///
  1.1410 +  /// \sa ShiftMap
  1.1411 +  template<typename M, typename C = typename M::Value>
  1.1412    class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
  1.1413 -    M& m;
  1.1414 -    C v;
  1.1415 +    M &_m;
  1.1416 +    C _v;
  1.1417    public:
  1.1418      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1419      typedef typename Parent::Key Key;
  1.1420      typedef typename Parent::Value Value;
  1.1421  
  1.1422 -    ///Constructor
  1.1423 +    /// Constructor
  1.1424  
  1.1425 -    ///Constructor.
  1.1426 -    ///\param _m is the undelying map.
  1.1427 -    ///\param _v is the shift value.
  1.1428 -    ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
  1.1429 +    /// Constructor.
  1.1430 +    /// \param m The undelying map.
  1.1431 +    /// \param v The constant value.
  1.1432 +    ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {}
  1.1433      /// \e
  1.1434 -    Value operator[](Key k) const {return m[k] + v;}
  1.1435 +    Value operator[](const Key &k) const { return _m[k]+_v; }
  1.1436      /// \e
  1.1437 -    void set(Key k, const Value& c) { m.set(k, c - v); }
  1.1438 +    void set(const Key &k, const Value &v) { _m.set(k, v-_v); }
  1.1439    };
  1.1440 -  
  1.1441 -  ///Returns a \c ShiftMap class
  1.1442  
  1.1443 -  ///This function just returns a \c ShiftMap class.
  1.1444 -  ///\relates ShiftMap
  1.1445 -  template<typename M, typename C> 
  1.1446 -  inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
  1.1447 +  /// Returns a \ref ShiftMap class
  1.1448 +
  1.1449 +  /// This function just returns a \ref ShiftMap class.
  1.1450 +  ///
  1.1451 +  /// For example, if \c m is a map with \c double values and \c v is
  1.1452 +  /// \c double, then <tt>shiftMap(m,v)[x]</tt> will be equal to
  1.1453 +  /// <tt>m[x]+v</tt>.
  1.1454 +  ///
  1.1455 +  /// \relates ShiftMap
  1.1456 +  template<typename M, typename C>
  1.1457 +  inline ShiftMap<M, C> shiftMap(const M &m, const C &v) {
  1.1458      return ShiftMap<M, C>(m,v);
  1.1459    }
  1.1460  
  1.1461 -  ///Returns a \c ShiftWriteMap class
  1.1462 +  /// Returns a \ref ShiftWriteMap class
  1.1463  
  1.1464 -  ///This function just returns a \c ShiftWriteMap class.
  1.1465 -  ///\relates ShiftWriteMap
  1.1466 -  template<typename M, typename C> 
  1.1467 -  inline ShiftWriteMap<M, C> shiftMap(M &m,const C &v) {
  1.1468 +  /// This function just returns a \ref ShiftWriteMap class.
  1.1469 +  ///
  1.1470 +  /// For example, if \c m is a map with \c double values and \c v is
  1.1471 +  /// \c double, then <tt>shiftWriteMap(m,v)[x]</tt> will be equal to
  1.1472 +  /// <tt>m[x]+v</tt>.
  1.1473 +  /// Moreover it makes also possible to write the map.
  1.1474 +  ///
  1.1475 +  /// \relates ShiftWriteMap
  1.1476 +  template<typename M, typename C>
  1.1477 +  inline ShiftWriteMap<M, C> shiftWriteMap(M &m, const C &v) {
  1.1478      return ShiftWriteMap<M, C>(m,v);
  1.1479    }
  1.1480  
  1.1481 -  ///Difference of two maps
  1.1482  
  1.1483 -  ///This \ref concepts::ReadMap "read only map" returns the difference
  1.1484 -  ///of the values of the two given maps.
  1.1485 -  ///Its \c Key and \c Value are inherited from \c M1.
  1.1486 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  1.1487 +  /// Scales a map with a constant.
  1.1488 +
  1.1489 +  /// This \ref concepts::ReadMap "read only map" returns the value of
  1.1490 +  /// the given map multiplied from the left side with a constant value.
  1.1491 +  /// Its \c Key and \c Value are inherited from \c M.
  1.1492    ///
  1.1493 -  /// \todo Revise the misleading name
  1.1494 -  template<typename M1, typename M2> 
  1.1495 -  class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1496 -    const M1& m1;
  1.1497 -    const M2& m2;
  1.1498 -  public:
  1.1499 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1500 -    typedef typename Parent::Key Key;
  1.1501 -    typedef typename Parent::Value Value;
  1.1502 -
  1.1503 -    ///Constructor
  1.1504 -    SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  1.1505 -    /// \e
  1.1506 -    Value operator[](Key k) const {return m1[k]-m2[k];}
  1.1507 -  };
  1.1508 -  
  1.1509 -  ///Returns a \c SubMap class
  1.1510 -
  1.1511 -  ///This function just returns a \c SubMap class.
  1.1512 +  /// Actually,
  1.1513 +  /// \code
  1.1514 +  ///   ScaleMap<M> sc(m,v);
  1.1515 +  /// \endcode
  1.1516 +  /// is equivalent to
  1.1517 +  /// \code
  1.1518 +  ///   ConstMap<M::Key, M::Value> cm(v);
  1.1519 +  ///   MulMap<ConstMap<M::Key, M::Value>, M> sc(cm,m);
  1.1520 +  /// \endcode
  1.1521    ///
  1.1522 -  ///\relates SubMap
  1.1523 -  template<typename M1, typename M2> 
  1.1524 -  inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
  1.1525 -    return SubMap<M1, M2>(m1, m2);
  1.1526 -  }
  1.1527 -
  1.1528 -  ///Product of two maps
  1.1529 -
  1.1530 -  ///This \ref concepts::ReadMap "read only map" returns the product of the
  1.1531 -  ///values of the two given maps.
  1.1532 -  ///Its \c Key and \c Value are inherited from \c M1.
  1.1533 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  1.1534 -  template<typename M1, typename M2> 
  1.1535 -  class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1536 -    const M1& m1;
  1.1537 -    const M2& m2;
  1.1538 -  public:
  1.1539 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1540 -    typedef typename Parent::Key Key;
  1.1541 -    typedef typename Parent::Value Value;
  1.1542 -
  1.1543 -    ///Constructor
  1.1544 -    MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  1.1545 -    /// \e
  1.1546 -    Value operator[](Key k) const {return m1[k]*m2[k];}
  1.1547 -  };
  1.1548 -  
  1.1549 -  ///Returns a \c MulMap class
  1.1550 -
  1.1551 -  ///This function just returns a \c MulMap class.
  1.1552 -  ///\relates MulMap
  1.1553 -  template<typename M1, typename M2> 
  1.1554 -  inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
  1.1555 -    return MulMap<M1, M2>(m1,m2);
  1.1556 -  }
  1.1557 - 
  1.1558 -  ///Scales a map with a constant.
  1.1559 -
  1.1560 -  ///This \ref concepts::ReadMap "read only map" returns the value of the
  1.1561 -  ///given map multiplied from the left side with a constant value.
  1.1562 -  ///Its \c Key and \c Value are inherited from \c M.
  1.1563 +  /// The simplest way of using this map is through the scaleMap()
  1.1564 +  /// function.
  1.1565    ///
  1.1566 -  ///Actually,
  1.1567 -  ///\code
  1.1568 -  ///  ScaleMap<X> sc(x,v);
  1.1569 -  ///\endcode
  1.1570 -  ///is equivalent to
  1.1571 -  ///\code
  1.1572 -  ///  ConstMap<X::Key, X::Value> c_tmp(v);
  1.1573 -  ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
  1.1574 -  ///\endcode
  1.1575 -  ///
  1.1576 -  ///\sa ScaleWriteMap
  1.1577 -  template<typename M, typename C = typename M::Value> 
  1.1578 +  /// \sa ScaleWriteMap
  1.1579 +  template<typename M, typename C = typename M::Value>
  1.1580    class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
  1.1581 -    const M& m;
  1.1582 -    C v;
  1.1583 +    const M &_m;
  1.1584 +    C _v;
  1.1585    public:
  1.1586      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1587      typedef typename Parent::Key Key;
  1.1588      typedef typename Parent::Value Value;
  1.1589  
  1.1590 -    ///Constructor
  1.1591 +    /// Constructor
  1.1592  
  1.1593 -    ///Constructor.
  1.1594 -    ///\param _m is the undelying map.
  1.1595 -    ///\param _v is the scaling value.
  1.1596 -    ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
  1.1597 +    /// Constructor.
  1.1598 +    /// \param m The undelying map.
  1.1599 +    /// \param v The constant value.
  1.1600 +    ScaleMap(const M &m, const C &v) : _m(m), _v(v) {}
  1.1601      /// \e
  1.1602 -    Value operator[](Key k) const {return v * m[k];}
  1.1603 +    Value operator[](const Key &k) const { return _v*_m[k]; }
  1.1604    };
  1.1605  
  1.1606 -  ///Scales a map with a constant (ReadWrite version).
  1.1607 +  /// Scales a map with a constant (read-write version).
  1.1608  
  1.1609 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
  1.1610 -  ///given map multiplied from the left side with a constant value. It can
  1.1611 -  ///also be used as write map if the \c / operator is defined between
  1.1612 -  ///\c Value and \c C and the given multiplier is not zero.
  1.1613 -  ///Its \c Key and \c Value are inherited from \c M.
  1.1614 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the value of
  1.1615 +  /// the given map multiplied from the left side with a constant value.
  1.1616 +  /// Its \c Key and \c Value are inherited from \c M.
  1.1617 +  /// It can also be used as write map if the \c / operator is defined
  1.1618 +  /// between \c Value and \c C and the given multiplier is not zero.
  1.1619    ///
  1.1620 -  ///\sa ScaleMap
  1.1621 -  template<typename M, typename C = typename M::Value> 
  1.1622 +  /// The simplest way of using this map is through the scaleWriteMap()
  1.1623 +  /// function.
  1.1624 +  ///
  1.1625 +  /// \sa ScaleMap
  1.1626 +  template<typename M, typename C = typename M::Value>
  1.1627    class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
  1.1628 -    M& m;
  1.1629 -    C v;
  1.1630 +    M &_m;
  1.1631 +    C _v;
  1.1632    public:
  1.1633      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1634      typedef typename Parent::Key Key;
  1.1635      typedef typename Parent::Value Value;
  1.1636  
  1.1637 -    ///Constructor
  1.1638 +    /// Constructor
  1.1639  
  1.1640 -    ///Constructor.
  1.1641 -    ///\param _m is the undelying map.
  1.1642 -    ///\param _v is the scaling value.
  1.1643 -    ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
  1.1644 +    /// Constructor.
  1.1645 +    /// \param m The undelying map.
  1.1646 +    /// \param v The constant value.
  1.1647 +    ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {}
  1.1648      /// \e
  1.1649 -    Value operator[](Key k) const {return v * m[k];}
  1.1650 +    Value operator[](const Key &k) const { return _v*_m[k]; }
  1.1651      /// \e
  1.1652 -    void set(Key k, const Value& c) { m.set(k, c / v);}
  1.1653 +    void set(const Key &k, const Value &v) { _m.set(k, v/_v); }
  1.1654    };
  1.1655 -  
  1.1656 -  ///Returns a \c ScaleMap class
  1.1657  
  1.1658 -  ///This function just returns a \c ScaleMap class.
  1.1659 -  ///\relates ScaleMap
  1.1660 -  template<typename M, typename C> 
  1.1661 -  inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
  1.1662 +  /// Returns a \ref ScaleMap class
  1.1663 +
  1.1664 +  /// This function just returns a \ref ScaleMap class.
  1.1665 +  ///
  1.1666 +  /// For example, if \c m is a map with \c double values and \c v is
  1.1667 +  /// \c double, then <tt>scaleMap(m,v)[x]</tt> will be equal to
  1.1668 +  /// <tt>v*m[x]</tt>.
  1.1669 +  ///
  1.1670 +  /// \relates ScaleMap
  1.1671 +  template<typename M, typename C>
  1.1672 +  inline ScaleMap<M, C> scaleMap(const M &m, const C &v) {
  1.1673      return ScaleMap<M, C>(m,v);
  1.1674    }
  1.1675  
  1.1676 -  ///Returns a \c ScaleWriteMap class
  1.1677 +  /// Returns a \ref ScaleWriteMap class
  1.1678  
  1.1679 -  ///This function just returns a \c ScaleWriteMap class.
  1.1680 -  ///\relates ScaleWriteMap
  1.1681 -  template<typename M, typename C> 
  1.1682 -  inline ScaleWriteMap<M, C> scaleMap(M &m,const C &v) {
  1.1683 +  /// This function just returns a \ref ScaleWriteMap class.
  1.1684 +  ///
  1.1685 +  /// For example, if \c m is a map with \c double values and \c v is
  1.1686 +  /// \c double, then <tt>scaleWriteMap(m,v)[x]</tt> will be equal to
  1.1687 +  /// <tt>v*m[x]</tt>.
  1.1688 +  /// Moreover it makes also possible to write the map.
  1.1689 +  ///
  1.1690 +  /// \relates ScaleWriteMap
  1.1691 +  template<typename M, typename C>
  1.1692 +  inline ScaleWriteMap<M, C> scaleWriteMap(M &m, const C &v) {
  1.1693      return ScaleWriteMap<M, C>(m,v);
  1.1694    }
  1.1695  
  1.1696 -  ///Quotient of two maps
  1.1697  
  1.1698 -  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
  1.1699 -  ///values of the two given maps.
  1.1700 -  ///Its \c Key and \c Value are inherited from \c M1.
  1.1701 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  1.1702 -  template<typename M1, typename M2> 
  1.1703 -  class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.1704 -    const M1& m1;
  1.1705 -    const M2& m2;
  1.1706 -  public:
  1.1707 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.1708 -    typedef typename Parent::Key Key;
  1.1709 -    typedef typename Parent::Value Value;
  1.1710 +  /// Negative of a map
  1.1711  
  1.1712 -    ///Constructor
  1.1713 -    DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  1.1714 -    /// \e
  1.1715 -    Value operator[](Key k) const {return m1[k]/m2[k];}
  1.1716 -  };
  1.1717 -  
  1.1718 -  ///Returns a \c DivMap class
  1.1719 -
  1.1720 -  ///This function just returns a \c DivMap class.
  1.1721 -  ///\relates DivMap
  1.1722 -  template<typename M1, typename M2> 
  1.1723 -  inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
  1.1724 -    return DivMap<M1, M2>(m1,m2);
  1.1725 -  }
  1.1726 -  
  1.1727 -  ///Composition of two maps
  1.1728 -
  1.1729 -  ///This \ref concepts::ReadMap "read only map" returns the composition of
  1.1730 -  ///two given maps.
  1.1731 -  ///That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2,
  1.1732 -  ///then for
  1.1733 -  ///\code
  1.1734 -  ///  ComposeMap<M1, M2> cm(m1,m2);
  1.1735 -  ///\endcode
  1.1736 -  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
  1.1737 +  /// This \ref concepts::ReadMap "read only map" returns the negative
  1.1738 +  /// of the values of the given map (using the unary \c - operator).
  1.1739 +  /// Its \c Key and \c Value are inherited from \c M.
  1.1740    ///
  1.1741 -  ///Its \c Key is inherited from \c M2 and its \c Value is from \c M1.
  1.1742 -  ///\c M2::Value must be convertible to \c M1::Key.
  1.1743 +  /// If M::Value is \c int, \c double etc., then
  1.1744 +  /// \code
  1.1745 +  ///   NegMap<M> neg(m);
  1.1746 +  /// \endcode
  1.1747 +  /// is equivalent to
  1.1748 +  /// \code
  1.1749 +  ///   ScaleMap<M> neg(m,-1);
  1.1750 +  /// \endcode
  1.1751    ///
  1.1752 -  ///\sa CombineMap
  1.1753 +  /// The simplest way of using this map is through the negMap()
  1.1754 +  /// function.
  1.1755    ///
  1.1756 -  ///\todo Check the requirements.
  1.1757 -  template <typename M1, typename M2> 
  1.1758 -  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
  1.1759 -    const M1& m1;
  1.1760 -    const M2& m2;
  1.1761 -  public:
  1.1762 -    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
  1.1763 -    typedef typename Parent::Key Key;
  1.1764 -    typedef typename Parent::Value Value;
  1.1765 -
  1.1766 -    ///Constructor
  1.1767 -    ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  1.1768 -    
  1.1769 -    /// \e
  1.1770 -
  1.1771 -
  1.1772 -    /// \todo Use the  MapTraits once it is ported.
  1.1773 -    ///
  1.1774 -
  1.1775 -    //typename MapTraits<M1>::ConstReturnValue
  1.1776 -    typename M1::Value
  1.1777 -    operator[](Key k) const {return m1[m2[k]];}
  1.1778 -  };
  1.1779 -
  1.1780 -  ///Returns a \c ComposeMap class
  1.1781 -
  1.1782 -  ///This function just returns a \c ComposeMap class.
  1.1783 -  ///\relates ComposeMap
  1.1784 -  template <typename M1, typename M2> 
  1.1785 -  inline ComposeMap<M1, M2> composeMap(const M1 &m1,const M2 &m2) {
  1.1786 -    return ComposeMap<M1, M2>(m1,m2);
  1.1787 -  }
  1.1788 -  
  1.1789 -  ///Combine of two maps using an STL (binary) functor.
  1.1790 -
  1.1791 -  ///Combine of two maps using an STL (binary) functor.
  1.1792 -  ///
  1.1793 -  ///This \ref concepts::ReadMap "read only map" takes two maps and a
  1.1794 -  ///binary functor and returns the composition of the two
  1.1795 -  ///given maps unsing the functor. 
  1.1796 -  ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
  1.1797 -  ///and \c f is of \c F, then for
  1.1798 -  ///\code
  1.1799 -  ///  CombineMap<M1,M2,F,V> cm(m1,m2,f);
  1.1800 -  ///\endcode
  1.1801 -  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>
  1.1802 -  ///
  1.1803 -  ///Its \c Key is inherited from \c M1 and its \c Value is \c V.
  1.1804 -  ///\c M2::Value and \c M1::Value must be convertible to the corresponding
  1.1805 -  ///input parameter of \c F and the return type of \c F must be convertible
  1.1806 -  ///to \c V.
  1.1807 -  ///
  1.1808 -  ///\sa ComposeMap
  1.1809 -  ///
  1.1810 -  ///\todo Check the requirements.
  1.1811 -  template<typename M1, typename M2, typename F,
  1.1812 -	   typename V = typename F::result_type> 
  1.1813 -  class CombineMap : public MapBase<typename M1::Key, V> {
  1.1814 -    const M1& m1;
  1.1815 -    const M2& m2;
  1.1816 -    F f;
  1.1817 -  public:
  1.1818 -    typedef MapBase<typename M1::Key, V> Parent;
  1.1819 -    typedef typename Parent::Key Key;
  1.1820 -    typedef typename Parent::Value Value;
  1.1821 -
  1.1822 -    ///Constructor
  1.1823 -    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f = F())
  1.1824 -      : m1(_m1), m2(_m2), f(_f) {};
  1.1825 -    /// \e
  1.1826 -    Value operator[](Key k) const {return f(m1[k],m2[k]);}
  1.1827 -  };
  1.1828 -  
  1.1829 -  ///Returns a \c CombineMap class
  1.1830 -
  1.1831 -  ///This function just returns a \c CombineMap class.
  1.1832 -  ///
  1.1833 -  ///For example if \c m1 and \c m2 are both \c double valued maps, then 
  1.1834 -  ///\code
  1.1835 -  ///combineMap(m1,m2,std::plus<double>())
  1.1836 -  ///\endcode
  1.1837 -  ///is equivalent to
  1.1838 -  ///\code
  1.1839 -  ///addMap(m1,m2)
  1.1840 -  ///\endcode
  1.1841 -  ///
  1.1842 -  ///This function is specialized for adaptable binary function
  1.1843 -  ///classes and C++ functions.
  1.1844 -  ///
  1.1845 -  ///\relates CombineMap
  1.1846 -  template<typename M1, typename M2, typename F, typename V> 
  1.1847 -  inline CombineMap<M1, M2, F, V> 
  1.1848 -  combineMap(const M1& m1,const M2& m2, const F& f) {
  1.1849 -    return CombineMap<M1, M2, F, V>(m1,m2,f);
  1.1850 -  }
  1.1851 -
  1.1852 -  template<typename M1, typename M2, typename F> 
  1.1853 -  inline CombineMap<M1, M2, F, typename F::result_type> 
  1.1854 -  combineMap(const M1& m1, const M2& m2, const F& f) {
  1.1855 -    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
  1.1856 -  }
  1.1857 -
  1.1858 -  template<typename M1, typename M2, typename K1, typename K2, typename V> 
  1.1859 -  inline CombineMap<M1, M2, V (*)(K1, K2), V> 
  1.1860 -  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
  1.1861 -    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
  1.1862 -  }
  1.1863 -
  1.1864 -  ///Negative value of a map
  1.1865 -
  1.1866 -  ///This \ref concepts::ReadMap "read only map" returns the negative
  1.1867 -  ///value of the value returned by the given map.
  1.1868 -  ///Its \c Key and \c Value are inherited from \c M.
  1.1869 -  ///The unary \c - operator must be defined for \c Value, of course.
  1.1870 -  ///
  1.1871 -  ///\sa NegWriteMap
  1.1872 -  template<typename M> 
  1.1873 +  /// \sa NegWriteMap
  1.1874 +  template<typename M>
  1.1875    class NegMap : public MapBase<typename M::Key, typename M::Value> {
  1.1876 -    const M& m;
  1.1877 +    const M& _m;
  1.1878    public:
  1.1879      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1880      typedef typename Parent::Key Key;
  1.1881      typedef typename Parent::Value Value;
  1.1882  
  1.1883 -    ///Constructor
  1.1884 -    NegMap(const M &_m) : m(_m) {};
  1.1885 +    /// Constructor
  1.1886 +    NegMap(const M &m) : _m(m) {}
  1.1887      /// \e
  1.1888 -    Value operator[](Key k) const {return -m[k];}
  1.1889 +    Value operator[](const Key &k) const { return -_m[k]; }
  1.1890    };
  1.1891 -  
  1.1892 -  ///Negative value of a map (ReadWrite version)
  1.1893  
  1.1894 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
  1.1895 -  ///value of the value returned by the given map.
  1.1896 -  ///Its \c Key and \c Value are inherited from \c M.
  1.1897 -  ///The unary \c - operator must be defined for \c Value, of course.
  1.1898 +  /// Negative of a map (read-write version)
  1.1899 +
  1.1900 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the
  1.1901 +  /// negative of the values of the given map (using the unary \c -
  1.1902 +  /// operator).
  1.1903 +  /// Its \c Key and \c Value are inherited from \c M.
  1.1904 +  /// It makes also possible to write the map.
  1.1905 +  ///
  1.1906 +  /// If M::Value is \c int, \c double etc., then
  1.1907 +  /// \code
  1.1908 +  ///   NegWriteMap<M> neg(m);
  1.1909 +  /// \endcode
  1.1910 +  /// is equivalent to
  1.1911 +  /// \code
  1.1912 +  ///   ScaleWriteMap<M> neg(m,-1);
  1.1913 +  /// \endcode
  1.1914 +  ///
  1.1915 +  /// The simplest way of using this map is through the negWriteMap()
  1.1916 +  /// function.
  1.1917    ///
  1.1918    /// \sa NegMap
  1.1919 -  template<typename M> 
  1.1920 +  template<typename M>
  1.1921    class NegWriteMap : public MapBase<typename M::Key, typename M::Value> {
  1.1922 -    M& m;
  1.1923 +    M &_m;
  1.1924    public:
  1.1925      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.1926      typedef typename Parent::Key Key;
  1.1927      typedef typename Parent::Value Value;
  1.1928  
  1.1929 -    ///Constructor
  1.1930 -    NegWriteMap(M &_m) : m(_m) {};
  1.1931 +    /// Constructor
  1.1932 +    NegWriteMap(M &m) : _m(m) {}
  1.1933      /// \e
  1.1934 -    Value operator[](Key k) const {return -m[k];}
  1.1935 +    Value operator[](const Key &k) const { return -_m[k]; }
  1.1936      /// \e
  1.1937 -    void set(Key k, const Value& v) { m.set(k, -v); }
  1.1938 +    void set(const Key &k, const Value &v) { _m.set(k, -v); }
  1.1939    };
  1.1940  
  1.1941 -  ///Returns a \c NegMap class
  1.1942 +  /// Returns a \ref NegMap class
  1.1943  
  1.1944 -  ///This function just returns a \c NegMap class.
  1.1945 -  ///\relates NegMap
  1.1946 -  template <typename M> 
  1.1947 +  /// This function just returns a \ref NegMap class.
  1.1948 +  ///
  1.1949 +  /// For example, if \c m is a map with \c double values, then
  1.1950 +  /// <tt>negMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
  1.1951 +  ///
  1.1952 +  /// \relates NegMap
  1.1953 +  template <typename M>
  1.1954    inline NegMap<M> negMap(const M &m) {
  1.1955      return NegMap<M>(m);
  1.1956    }
  1.1957  
  1.1958 -  ///Returns a \c NegWriteMap class
  1.1959 +  /// Returns a \ref NegWriteMap class
  1.1960  
  1.1961 -  ///This function just returns a \c NegWriteMap class.
  1.1962 -  ///\relates NegWriteMap
  1.1963 -  template <typename M> 
  1.1964 -  inline NegWriteMap<M> negMap(M &m) {
  1.1965 +  /// This function just returns a \ref NegWriteMap class.
  1.1966 +  ///
  1.1967 +  /// For example, if \c m is a map with \c double values, then
  1.1968 +  /// <tt>negWriteMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
  1.1969 +  /// Moreover it makes also possible to write the map.
  1.1970 +  ///
  1.1971 +  /// \relates NegWriteMap
  1.1972 +  template <typename M>
  1.1973 +  inline NegWriteMap<M> negWriteMap(M &m) {
  1.1974      return NegWriteMap<M>(m);
  1.1975    }
  1.1976  
  1.1977 -  ///Absolute value of a map
  1.1978  
  1.1979 -  ///This \ref concepts::ReadMap "read only map" returns the absolute value
  1.1980 -  ///of the value returned by the given map.
  1.1981 -  ///Its \c Key and \c Value are inherited from \c M. 
  1.1982 -  ///\c Value must be comparable to \c 0 and the unary \c -
  1.1983 -  ///operator must be defined for it, of course.
  1.1984 -  template<typename M> 
  1.1985 +  /// Absolute value of a map
  1.1986 +
  1.1987 +  /// This \ref concepts::ReadMap "read only map" returns the absolute
  1.1988 +  /// value of the values of the given map.
  1.1989 +  /// Its \c Key and \c Value are inherited from \c M.
  1.1990 +  /// \c Value must be comparable to \c 0 and the unary \c -
  1.1991 +  /// operator must be defined for it, of course.
  1.1992 +  ///
  1.1993 +  /// The simplest way of using this map is through the absMap()
  1.1994 +  /// function.
  1.1995 +  template<typename M>
  1.1996    class AbsMap : public MapBase<typename M::Key, typename M::Value> {
  1.1997 -    const M& m;
  1.1998 +    const M &_m;
  1.1999    public:
  1.2000      typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.2001      typedef typename Parent::Key Key;
  1.2002      typedef typename Parent::Value Value;
  1.2003  
  1.2004 -    ///Constructor
  1.2005 -    AbsMap(const M &_m) : m(_m) {};
  1.2006 +    /// Constructor
  1.2007 +    AbsMap(const M &m) : _m(m) {}
  1.2008      /// \e
  1.2009 -    Value operator[](Key k) const {
  1.2010 -      Value tmp = m[k]; 
  1.2011 +    Value operator[](const Key &k) const {
  1.2012 +      Value tmp = _m[k];
  1.2013        return tmp >= 0 ? tmp : -tmp;
  1.2014      }
  1.2015  
  1.2016    };
  1.2017 -  
  1.2018 -  ///Returns an \c AbsMap class
  1.2019  
  1.2020 -  ///This function just returns an \c AbsMap class.
  1.2021 -  ///\relates AbsMap
  1.2022 -  template<typename M> 
  1.2023 +  /// Returns an \ref AbsMap class
  1.2024 +
  1.2025 +  /// This function just returns an \ref AbsMap class.
  1.2026 +  ///
  1.2027 +  /// For example, if \c m is a map with \c double values, then
  1.2028 +  /// <tt>absMap(m)[x]</tt> will be equal to <tt>m[x]</tt> if
  1.2029 +  /// it is positive or zero and <tt>-m[x]</tt> if <tt>m[x]</tt> is
  1.2030 +  /// negative.
  1.2031 +  ///
  1.2032 +  /// \relates AbsMap
  1.2033 +  template<typename M>
  1.2034    inline AbsMap<M> absMap(const M &m) {
  1.2035      return AbsMap<M>(m);
  1.2036    }
  1.2037  
  1.2038 -  ///Converts an STL style functor to a map
  1.2039  
  1.2040 -  ///This \ref concepts::ReadMap "read only map" returns the value
  1.2041 -  ///of a given functor.
  1.2042 +  /// Logical 'not' of a map
  1.2043 +
  1.2044 +  /// This \ref concepts::ReadMap "read only map" returns the logical
  1.2045 +  /// negation of the values of the given map.
  1.2046 +  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
  1.2047    ///
  1.2048 -  ///Template parameters \c K and \c V will become its
  1.2049 -  ///\c Key and \c Value. 
  1.2050 -  ///In most cases they have to be given explicitly because a 
  1.2051 -  ///functor typically does not provide \c argument_type and 
  1.2052 -  ///\c result_type typedefs.
  1.2053 +  /// The simplest way of using this map is through the notMap()
  1.2054 +  /// function.
  1.2055    ///
  1.2056 -  ///Parameter \c F is the type of the used functor.
  1.2057 -  ///
  1.2058 -  ///\sa MapFunctor
  1.2059 -  template<typename F, 
  1.2060 -	   typename K = typename F::argument_type, 
  1.2061 -	   typename V = typename F::result_type> 
  1.2062 -  class FunctorMap : public MapBase<K, V> {
  1.2063 -    F f;
  1.2064 -  public:
  1.2065 -    typedef MapBase<K, V> Parent;
  1.2066 -    typedef typename Parent::Key Key;
  1.2067 -    typedef typename Parent::Value Value;
  1.2068 -
  1.2069 -    ///Constructor
  1.2070 -    FunctorMap(const F &_f = F()) : f(_f) {}
  1.2071 -    /// \e
  1.2072 -    Value operator[](Key k) const { return f(k);}
  1.2073 -  };
  1.2074 -  
  1.2075 -  ///Returns a \c FunctorMap class
  1.2076 -
  1.2077 -  ///This function just returns a \c FunctorMap class.
  1.2078 -  ///
  1.2079 -  ///This function is specialized for adaptable binary function
  1.2080 -  ///classes and C++ functions.
  1.2081 -  ///
  1.2082 -  ///\relates FunctorMap
  1.2083 -  template<typename K, typename V, typename F> inline 
  1.2084 -  FunctorMap<F, K, V> functorMap(const F &f) {
  1.2085 -    return FunctorMap<F, K, V>(f);
  1.2086 -  }
  1.2087 -
  1.2088 -  template <typename F> inline 
  1.2089 -  FunctorMap<F, typename F::argument_type, typename F::result_type> 
  1.2090 -  functorMap(const F &f) {
  1.2091 -    return FunctorMap<F, typename F::argument_type, 
  1.2092 -      typename F::result_type>(f);
  1.2093 -  }
  1.2094 -
  1.2095 -  template <typename K, typename V> inline 
  1.2096 -  FunctorMap<V (*)(K), K, V> functorMap(V (*f)(K)) {
  1.2097 -    return FunctorMap<V (*)(K), K, V>(f);
  1.2098 -  }
  1.2099 -
  1.2100 -
  1.2101 -  ///Converts a map to an STL style (unary) functor
  1.2102 -
  1.2103 -  ///This class Converts a map to an STL style (unary) functor.
  1.2104 -  ///That is it provides an <tt>operator()</tt> to read its values.
  1.2105 -  ///
  1.2106 -  ///For the sake of convenience it also works as
  1.2107 -  ///a ususal \ref concepts::ReadMap "readable map",
  1.2108 -  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
  1.2109 -  ///
  1.2110 -  ///\sa FunctorMap
  1.2111 -  template <typename M> 
  1.2112 -  class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
  1.2113 -    const M& m;
  1.2114 -  public:
  1.2115 -    typedef MapBase<typename M::Key, typename M::Value> Parent;
  1.2116 -    typedef typename Parent::Key Key;
  1.2117 -    typedef typename Parent::Value Value;
  1.2118 -
  1.2119 -    typedef typename M::Key argument_type;
  1.2120 -    typedef typename M::Value result_type;
  1.2121 -
  1.2122 -    ///Constructor
  1.2123 -    MapFunctor(const M &_m) : m(_m) {};
  1.2124 -    ///\e
  1.2125 -    Value operator()(Key k) const {return m[k];}
  1.2126 -    ///\e
  1.2127 -    Value operator[](Key k) const {return m[k];}
  1.2128 -  };
  1.2129 -  
  1.2130 -  ///Returns a \c MapFunctor class
  1.2131 -
  1.2132 -  ///This function just returns a \c MapFunctor class.
  1.2133 -  ///\relates MapFunctor
  1.2134 -  template<typename M> 
  1.2135 -  inline MapFunctor<M> mapFunctor(const M &m) {
  1.2136 -    return MapFunctor<M>(m);
  1.2137 -  }
  1.2138 -
  1.2139 -  ///Just readable version of \ref ForkWriteMap
  1.2140 -
  1.2141 -  ///This map has two \ref concepts::ReadMap "readable map"
  1.2142 -  ///parameters and each read request will be passed just to the
  1.2143 -  ///first map. This class is the just readable map type of \c ForkWriteMap.
  1.2144 -  ///
  1.2145 -  ///The \c Key and \c Value are inherited from \c M1.
  1.2146 -  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
  1.2147 -  ///
  1.2148 -  ///\sa ForkWriteMap
  1.2149 -  ///
  1.2150 -  /// \todo Why is it needed?
  1.2151 -  template<typename  M1, typename M2> 
  1.2152 -  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.2153 -    const M1& m1;
  1.2154 -    const M2& m2;
  1.2155 -  public:
  1.2156 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.2157 -    typedef typename Parent::Key Key;
  1.2158 -    typedef typename Parent::Value Value;
  1.2159 -
  1.2160 -    ///Constructor
  1.2161 -    ForkMap(const M1 &_m1, const M2 &_m2) : m1(_m1), m2(_m2) {};
  1.2162 -    /// \e
  1.2163 -    Value operator[](Key k) const {return m1[k];}
  1.2164 -  };
  1.2165 -
  1.2166 -
  1.2167 -  ///Applies all map setting operations to two maps
  1.2168 -
  1.2169 -  ///This map has two \ref concepts::WriteMap "writable map"
  1.2170 -  ///parameters and each write request will be passed to both of them.
  1.2171 -  ///If \c M1 is also \ref concepts::ReadMap "readable",
  1.2172 -  ///then the read operations will return the
  1.2173 -  ///corresponding values of \c M1.
  1.2174 -  ///
  1.2175 -  ///The \c Key and \c Value are inherited from \c M1.
  1.2176 -  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
  1.2177 -  ///
  1.2178 -  ///\sa ForkMap
  1.2179 -  template<typename  M1, typename M2> 
  1.2180 -  class ForkWriteMap : public MapBase<typename M1::Key, typename M1::Value> {
  1.2181 -    M1& m1;
  1.2182 -    M2& m2;
  1.2183 -  public:
  1.2184 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  1.2185 -    typedef typename Parent::Key Key;
  1.2186 -    typedef typename Parent::Value Value;
  1.2187 -
  1.2188 -    ///Constructor
  1.2189 -    ForkWriteMap(M1 &_m1, M2 &_m2) : m1(_m1), m2(_m2) {};
  1.2190 -    ///\e
  1.2191 -    Value operator[](Key k) const {return m1[k];}
  1.2192 -    ///\e
  1.2193 -    void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);}
  1.2194 -  };
  1.2195 -  
  1.2196 -  ///Returns a \c ForkMap class
  1.2197 -
  1.2198 -  ///This function just returns a \c ForkMap class.
  1.2199 -  ///\relates ForkMap
  1.2200 -  template <typename M1, typename M2> 
  1.2201 -  inline ForkMap<M1, M2> forkMap(const M1 &m1, const M2 &m2) {
  1.2202 -    return ForkMap<M1, M2>(m1,m2);
  1.2203 -  }
  1.2204 -
  1.2205 -  ///Returns a \c ForkWriteMap class
  1.2206 -
  1.2207 -  ///This function just returns a \c ForkWriteMap class.
  1.2208 -  ///\relates ForkWriteMap
  1.2209 -  template <typename M1, typename M2> 
  1.2210 -  inline ForkWriteMap<M1, M2> forkMap(M1 &m1, M2 &m2) {
  1.2211 -    return ForkWriteMap<M1, M2>(m1,m2);
  1.2212 -  }
  1.2213 -
  1.2214 -
  1.2215 -  
  1.2216 -  /* ************* BOOL MAPS ******************* */
  1.2217 -  
  1.2218 -  ///Logical 'not' of a map
  1.2219 -  
  1.2220 -  ///This bool \ref concepts::ReadMap "read only map" returns the 
  1.2221 -  ///logical negation of the value returned by the given map.
  1.2222 -  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
  1.2223 -  ///
  1.2224 -  ///\sa NotWriteMap
  1.2225 -  template <typename M> 
  1.2226 +  /// \sa NotWriteMap
  1.2227 +  template <typename M>
  1.2228    class NotMap : public MapBase<typename M::Key, bool> {
  1.2229 -    const M& m;
  1.2230 +    const M &_m;
  1.2231    public:
  1.2232      typedef MapBase<typename M::Key, bool> Parent;
  1.2233      typedef typename Parent::Key Key;
  1.2234      typedef typename Parent::Value Value;
  1.2235  
  1.2236      /// Constructor
  1.2237 -    NotMap(const M &_m) : m(_m) {};
  1.2238 -    ///\e
  1.2239 -    Value operator[](Key k) const {return !m[k];}
  1.2240 +    NotMap(const M &m) : _m(m) {}
  1.2241 +    /// \e
  1.2242 +    Value operator[](const Key &k) const { return !_m[k]; }
  1.2243    };
  1.2244  
  1.2245 -  ///Logical 'not' of a map (ReadWrie version)
  1.2246 -  
  1.2247 -  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
  1.2248 -  ///logical negation of the value returned by the given map. When it is set,
  1.2249 -  ///the opposite value is set to the original map.
  1.2250 -  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
  1.2251 +  /// Logical 'not' of a map (read-write version)
  1.2252 +
  1.2253 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the
  1.2254 +  /// logical negation of the values of the given map.
  1.2255 +  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
  1.2256 +  /// It makes also possible to write the map. When a value is set,
  1.2257 +  /// the opposite value is set to the original map.
  1.2258    ///
  1.2259 -  ///\sa NotMap
  1.2260 -  template <typename M> 
  1.2261 +  /// The simplest way of using this map is through the notWriteMap()
  1.2262 +  /// function.
  1.2263 +  ///
  1.2264 +  /// \sa NotMap
  1.2265 +  template <typename M>
  1.2266    class NotWriteMap : public MapBase<typename M::Key, bool> {
  1.2267 -    M& m;
  1.2268 +    M &_m;
  1.2269    public:
  1.2270      typedef MapBase<typename M::Key, bool> Parent;
  1.2271      typedef typename Parent::Key Key;
  1.2272      typedef typename Parent::Value Value;
  1.2273  
  1.2274      /// Constructor
  1.2275 -    NotWriteMap(M &_m) : m(_m) {};
  1.2276 -    ///\e
  1.2277 -    Value operator[](Key k) const {return !m[k];}
  1.2278 -    ///\e
  1.2279 -    void set(Key k, bool v) { m.set(k, !v); }
  1.2280 +    NotWriteMap(M &m) : _m(m) {}
  1.2281 +    /// \e
  1.2282 +    Value operator[](const Key &k) const { return !_m[k]; }
  1.2283 +    /// \e
  1.2284 +    void set(const Key &k, bool v) { _m.set(k, !v); }
  1.2285    };
  1.2286 -  
  1.2287 -  ///Returns a \c NotMap class
  1.2288 -  
  1.2289 -  ///This function just returns a \c NotMap class.
  1.2290 -  ///\relates NotMap
  1.2291 -  template <typename M> 
  1.2292 +
  1.2293 +  /// Returns a \ref NotMap class
  1.2294 +
  1.2295 +  /// This function just returns a \ref NotMap class.
  1.2296 +  ///
  1.2297 +  /// For example, if \c m is a map with \c bool values, then
  1.2298 +  /// <tt>notMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
  1.2299 +  ///
  1.2300 +  /// \relates NotMap
  1.2301 +  template <typename M>
  1.2302    inline NotMap<M> notMap(const M &m) {
  1.2303      return NotMap<M>(m);
  1.2304    }
  1.2305 -  
  1.2306 -  ///Returns a \c NotWriteMap class
  1.2307 -  
  1.2308 -  ///This function just returns a \c NotWriteMap class.
  1.2309 -  ///\relates NotWriteMap
  1.2310 -  template <typename M> 
  1.2311 -  inline NotWriteMap<M> notMap(M &m) {
  1.2312 +
  1.2313 +  /// Returns a \ref NotWriteMap class
  1.2314 +
  1.2315 +  /// This function just returns a \ref NotWriteMap class.
  1.2316 +  ///
  1.2317 +  /// For example, if \c m is a map with \c bool values, then
  1.2318 +  /// <tt>notWriteMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
  1.2319 +  /// Moreover it makes also possible to write the map.
  1.2320 +  ///
  1.2321 +  /// \relates NotWriteMap
  1.2322 +  template <typename M>
  1.2323 +  inline NotWriteMap<M> notWriteMap(M &m) {
  1.2324      return NotWriteMap<M>(m);
  1.2325    }
  1.2326  
  1.2327 +
  1.2328    namespace _maps_bits {
  1.2329  
  1.2330      template <typename Value>
  1.2331 @@ -1276,44 +1482,44 @@
  1.2332  
  1.2333      template <typename _Iterator>
  1.2334      struct IteratorTraits<_Iterator,
  1.2335 -      typename exists<typename _Iterator::container_type>::type> 
  1.2336 +      typename exists<typename _Iterator::container_type>::type>
  1.2337      {
  1.2338        typedef typename _Iterator::container_type::value_type Value;
  1.2339      };
  1.2340  
  1.2341    }
  1.2342 -  
  1.2343 +
  1.2344  
  1.2345    /// \brief Writable bool map for logging each \c true assigned element
  1.2346    ///
  1.2347 -  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging 
  1.2348 -  /// each \c true assigned element, i.e it copies all the keys set 
  1.2349 +  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging
  1.2350 +  /// each \c true assigned element, i.e it copies all the keys set
  1.2351    /// to \c true to the given iterator.
  1.2352    ///
  1.2353 -  /// \note The container of the iterator should contain space 
  1.2354 +  /// \note The container of the iterator should contain space
  1.2355    /// for each element.
  1.2356    ///
  1.2357 -  /// The following example shows how you can write the edges found by 
  1.2358 +  /// The following example shows how you can write the edges found by
  1.2359    /// the \ref Prim algorithm directly to the standard output.
  1.2360 -  ///\code
  1.2361 -  /// typedef IdMap<Graph, Edge> EdgeIdMap;
  1.2362 -  /// EdgeIdMap edgeId(graph);
  1.2363 +  /// \code
  1.2364 +  ///   typedef IdMap<Graph, Edge> EdgeIdMap;
  1.2365 +  ///   EdgeIdMap edgeId(graph);
  1.2366    ///
  1.2367 -  /// typedef MapFunctor<EdgeIdMap> EdgeIdFunctor;
  1.2368 -  /// EdgeIdFunctor edgeIdFunctor(edgeId);
  1.2369 +  ///   typedef MapToFunctor<EdgeIdMap> EdgeIdFunctor;
  1.2370 +  ///   EdgeIdFunctor edgeIdFunctor(edgeId);
  1.2371    ///
  1.2372 -  /// StoreBoolMap<ostream_iterator<int>, EdgeIdFunctor> 
  1.2373 -  ///   writerMap(ostream_iterator<int>(cout, " "), edgeIdFunctor);
  1.2374 +  ///   StoreBoolMap<ostream_iterator<int>, EdgeIdFunctor>
  1.2375 +  ///     writerMap(ostream_iterator<int>(cout, " "), edgeIdFunctor);
  1.2376    ///
  1.2377 -  /// prim(graph, cost, writerMap);
  1.2378 -  ///\endcode
  1.2379 +  ///   prim(graph, cost, writerMap);
  1.2380 +  /// \endcode
  1.2381    ///
  1.2382 -  ///\sa BackInserterBoolMap 
  1.2383 -  ///\sa FrontInserterBoolMap 
  1.2384 -  ///\sa InserterBoolMap 
  1.2385 +  /// \sa BackInserterBoolMap
  1.2386 +  /// \sa FrontInserterBoolMap
  1.2387 +  /// \sa InserterBoolMap
  1.2388    ///
  1.2389 -  ///\todo Revise the name of this class and the related ones.
  1.2390 -  template <typename _Iterator, 
  1.2391 +  /// \todo Revise the name of this class and the related ones.
  1.2392 +  template <typename _Iterator,
  1.2393              typename _Functor =
  1.2394              _maps_bits::Identity<typename _maps_bits::
  1.2395                                   IteratorTraits<_Iterator>::Value> >
  1.2396 @@ -1327,33 +1533,33 @@
  1.2397      typedef _Functor Functor;
  1.2398  
  1.2399      /// Constructor
  1.2400 -    StoreBoolMap(Iterator it, const Functor& functor = Functor()) 
  1.2401 +    StoreBoolMap(Iterator it, const Functor& functor = Functor())
  1.2402        : _begin(it), _end(it), _functor(functor) {}
  1.2403  
  1.2404      /// Gives back the given iterator set for the first key
  1.2405      Iterator begin() const {
  1.2406        return _begin;
  1.2407      }
  1.2408 - 
  1.2409 +
  1.2410      /// Gives back the the 'after the last' iterator
  1.2411      Iterator end() const {
  1.2412        return _end;
  1.2413      }
  1.2414  
  1.2415 -    /// The \c set function of the map
  1.2416 +    /// The set function of the map
  1.2417      void set(const Key& key, Value value) const {
  1.2418        if (value) {
  1.2419  	*_end++ = _functor(key);
  1.2420        }
  1.2421      }
  1.2422 -    
  1.2423 +
  1.2424    private:
  1.2425      Iterator _begin;
  1.2426      mutable Iterator _end;
  1.2427      Functor _functor;
  1.2428    };
  1.2429  
  1.2430 -  /// \brief Writable bool map for logging each \c true assigned element in 
  1.2431 +  /// \brief Writable bool map for logging each \c true assigned element in
  1.2432    /// a back insertable container.
  1.2433    ///
  1.2434    /// Writable bool map for logging each \c true assigned element by pushing
  1.2435 @@ -1362,15 +1568,15 @@
  1.2436    /// container. The next example shows how you can store the
  1.2437    /// edges found by the Prim algorithm in a vector.
  1.2438    ///
  1.2439 -  ///\code
  1.2440 -  /// vector<Edge> span_tree_edges;
  1.2441 -  /// BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges);
  1.2442 -  /// prim(graph, cost, inserter_map);
  1.2443 -  ///\endcode
  1.2444 +  /// \code
  1.2445 +  ///   vector<Edge> span_tree_edges;
  1.2446 +  ///   BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges);
  1.2447 +  ///   prim(graph, cost, inserter_map);
  1.2448 +  /// \endcode
  1.2449    ///
  1.2450 -  ///\sa StoreBoolMap
  1.2451 -  ///\sa FrontInserterBoolMap
  1.2452 -  ///\sa InserterBoolMap
  1.2453 +  /// \sa StoreBoolMap
  1.2454 +  /// \sa FrontInserterBoolMap
  1.2455 +  /// \sa InserterBoolMap
  1.2456    template <typename Container,
  1.2457              typename Functor =
  1.2458              _maps_bits::Identity<typename Container::value_type> >
  1.2459 @@ -1380,23 +1586,23 @@
  1.2460      typedef bool Value;
  1.2461  
  1.2462      /// Constructor
  1.2463 -    BackInserterBoolMap(Container& _container, 
  1.2464 -                        const Functor& _functor = Functor()) 
  1.2465 +    BackInserterBoolMap(Container& _container,
  1.2466 +                        const Functor& _functor = Functor())
  1.2467        : container(_container), functor(_functor) {}
  1.2468  
  1.2469 -    /// The \c set function of the map
  1.2470 +    /// The set function of the map
  1.2471      void set(const Key& key, Value value) {
  1.2472        if (value) {
  1.2473  	container.push_back(functor(key));
  1.2474        }
  1.2475      }
  1.2476 -    
  1.2477 +
  1.2478    private:
  1.2479      Container& container;
  1.2480      Functor functor;
  1.2481    };
  1.2482  
  1.2483 -  /// \brief Writable bool map for logging each \c true assigned element in 
  1.2484 +  /// \brief Writable bool map for logging each \c true assigned element in
  1.2485    /// a front insertable container.
  1.2486    ///
  1.2487    /// Writable bool map for logging each \c true assigned element by pushing
  1.2488 @@ -1404,8 +1610,8 @@
  1.2489    /// It can be used to retrieve the items into a standard
  1.2490    /// container. For example see \ref BackInserterBoolMap.
  1.2491    ///
  1.2492 -  ///\sa BackInserterBoolMap
  1.2493 -  ///\sa InserterBoolMap
  1.2494 +  /// \sa BackInserterBoolMap
  1.2495 +  /// \sa InserterBoolMap
  1.2496    template <typename Container,
  1.2497              typename Functor =
  1.2498              _maps_bits::Identity<typename Container::value_type> >
  1.2499 @@ -1416,39 +1622,39 @@
  1.2500  
  1.2501      /// Constructor
  1.2502      FrontInserterBoolMap(Container& _container,
  1.2503 -                         const Functor& _functor = Functor()) 
  1.2504 +                         const Functor& _functor = Functor())
  1.2505        : container(_container), functor(_functor) {}
  1.2506  
  1.2507 -    /// The \c set function of the map
  1.2508 +    /// The set function of the map
  1.2509      void set(const Key& key, Value value) {
  1.2510        if (value) {
  1.2511  	container.push_front(functor(key));
  1.2512        }
  1.2513      }
  1.2514 -    
  1.2515 +
  1.2516    private:
  1.2517 -    Container& container;    
  1.2518 +    Container& container;
  1.2519      Functor functor;
  1.2520    };
  1.2521  
  1.2522 -  /// \brief Writable bool map for storing each \c true assigned element in 
  1.2523 +  /// \brief Writable bool map for storing each \c true assigned element in
  1.2524    /// an insertable container.
  1.2525    ///
  1.2526 -  /// Writable bool map for storing each \c true assigned element in an 
  1.2527 +  /// Writable bool map for storing each \c true assigned element in an
  1.2528    /// insertable container. It will insert all the keys set to \c true into
  1.2529    /// the container.
  1.2530    ///
  1.2531    /// For example, if you want to store the cut arcs of the strongly
  1.2532    /// connected components in a set you can use the next code:
  1.2533    ///
  1.2534 -  ///\code
  1.2535 -  /// set<Arc> cut_arcs;
  1.2536 -  /// InserterBoolMap<set<Arc> > inserter_map(cut_arcs);
  1.2537 -  /// stronglyConnectedCutArcs(digraph, cost, inserter_map);
  1.2538 -  ///\endcode
  1.2539 +  /// \code
  1.2540 +  ///   set<Arc> cut_arcs;
  1.2541 +  ///   InserterBoolMap<set<Arc> > inserter_map(cut_arcs);
  1.2542 +  ///   stronglyConnectedCutArcs(digraph, cost, inserter_map);
  1.2543 +  /// \endcode
  1.2544    ///
  1.2545 -  ///\sa BackInserterBoolMap
  1.2546 -  ///\sa FrontInserterBoolMap
  1.2547 +  /// \sa BackInserterBoolMap
  1.2548 +  /// \sa FrontInserterBoolMap
  1.2549    template <typename Container,
  1.2550              typename Functor =
  1.2551              _maps_bits::Identity<typename Container::value_type> >
  1.2552 @@ -1458,13 +1664,13 @@
  1.2553      typedef bool Value;
  1.2554  
  1.2555      /// Constructor with specified iterator
  1.2556 -    
  1.2557 +
  1.2558      /// Constructor with specified iterator.
  1.2559      /// \param _container The container for storing the elements.
  1.2560      /// \param _it The elements will be inserted before this iterator.
  1.2561      /// \param _functor The functor that is used when an element is stored.
  1.2562      InserterBoolMap(Container& _container, typename Container::iterator _it,
  1.2563 -                    const Functor& _functor = Functor()) 
  1.2564 +                    const Functor& _functor = Functor())
  1.2565        : container(_container), it(_it), functor(_functor) {}
  1.2566  
  1.2567      /// Constructor
  1.2568 @@ -1476,45 +1682,45 @@
  1.2569      InserterBoolMap(Container& _container, const Functor& _functor = Functor())
  1.2570        : container(_container), it(_container.end()), functor(_functor) {}
  1.2571  
  1.2572 -    /// The \c set function of the map
  1.2573 +    /// The set function of the map
  1.2574      void set(const Key& key, Value value) {
  1.2575        if (value) {
  1.2576  	it = container.insert(it, functor(key));
  1.2577          ++it;
  1.2578        }
  1.2579      }
  1.2580 -    
  1.2581 +
  1.2582    private:
  1.2583      Container& container;
  1.2584      typename Container::iterator it;
  1.2585      Functor functor;
  1.2586    };
  1.2587  
  1.2588 -  /// \brief Writable bool map for filling each \c true assigned element with a 
  1.2589 +  /// \brief Writable bool map for filling each \c true assigned element with a
  1.2590    /// given value.
  1.2591    ///
  1.2592 -  /// Writable bool map for filling each \c true assigned element with a 
  1.2593 +  /// Writable bool map for filling each \c true assigned element with a
  1.2594    /// given value. The value can set the container.
  1.2595    ///
  1.2596    /// The following code finds the connected components of a graph
  1.2597    /// and stores it in the \c comp map:
  1.2598 -  ///\code
  1.2599 -  /// typedef Graph::NodeMap<int> ComponentMap;
  1.2600 -  /// ComponentMap comp(graph);
  1.2601 -  /// typedef FillBoolMap<Graph::NodeMap<int> > ComponentFillerMap;
  1.2602 -  /// ComponentFillerMap filler(comp, 0);
  1.2603 +  /// \code
  1.2604 +  ///   typedef Graph::NodeMap<int> ComponentMap;
  1.2605 +  ///   ComponentMap comp(graph);
  1.2606 +  ///   typedef FillBoolMap<Graph::NodeMap<int> > ComponentFillerMap;
  1.2607 +  ///   ComponentFillerMap filler(comp, 0);
  1.2608    ///
  1.2609 -  /// Dfs<Graph>::DefProcessedMap<ComponentFillerMap>::Create dfs(graph);
  1.2610 -  /// dfs.processedMap(filler);
  1.2611 -  /// dfs.init();
  1.2612 -  /// for (NodeIt it(graph); it != INVALID; ++it) {
  1.2613 -  ///   if (!dfs.reached(it)) {
  1.2614 -  ///     dfs.addSource(it);
  1.2615 -  ///     dfs.start();
  1.2616 -  ///     ++filler.fillValue();
  1.2617 +  ///   Dfs<Graph>::DefProcessedMap<ComponentFillerMap>::Create dfs(graph);
  1.2618 +  ///   dfs.processedMap(filler);
  1.2619 +  ///   dfs.init();
  1.2620 +  ///   for (NodeIt it(graph); it != INVALID; ++it) {
  1.2621 +  ///     if (!dfs.reached(it)) {
  1.2622 +  ///       dfs.addSource(it);
  1.2623 +  ///       dfs.start();
  1.2624 +  ///       ++filler.fillValue();
  1.2625 +  ///     }
  1.2626    ///   }
  1.2627 -  /// }
  1.2628 -  ///\endcode
  1.2629 +  /// \endcode
  1.2630    template <typename Map>
  1.2631    class FillBoolMap {
  1.2632    public:
  1.2633 @@ -1522,90 +1728,90 @@
  1.2634      typedef bool Value;
  1.2635  
  1.2636      /// Constructor
  1.2637 -    FillBoolMap(Map& _map, const typename Map::Value& _fill) 
  1.2638 +    FillBoolMap(Map& _map, const typename Map::Value& _fill)
  1.2639        : map(_map), fill(_fill) {}
  1.2640  
  1.2641      /// Constructor
  1.2642 -    FillBoolMap(Map& _map) 
  1.2643 +    FillBoolMap(Map& _map)
  1.2644        : map(_map), fill() {}
  1.2645  
  1.2646      /// Gives back the current fill value
  1.2647      const typename Map::Value& fillValue() const {
  1.2648        return fill;
  1.2649 -    } 
  1.2650 +    }
  1.2651  
  1.2652      /// Gives back the current fill value
  1.2653      typename Map::Value& fillValue() {
  1.2654        return fill;
  1.2655 -    } 
  1.2656 +    }
  1.2657  
  1.2658      /// Sets the current fill value
  1.2659      void fillValue(const typename Map::Value& _fill) {
  1.2660        fill = _fill;
  1.2661 -    } 
  1.2662 +    }
  1.2663  
  1.2664 -    /// The \c set function of the map
  1.2665 +    /// The set function of the map
  1.2666      void set(const Key& key, Value value) {
  1.2667        if (value) {
  1.2668  	map.set(key, fill);
  1.2669        }
  1.2670      }
  1.2671 -    
  1.2672 +
  1.2673    private:
  1.2674      Map& map;
  1.2675      typename Map::Value fill;
  1.2676    };
  1.2677  
  1.2678  
  1.2679 -  /// \brief Writable bool map for storing the sequence number of 
  1.2680 -  /// \c true assignments.  
  1.2681 -  /// 
  1.2682 -  /// Writable bool map that stores for each \c true assigned elements  
  1.2683 +  /// \brief Writable bool map for storing the sequence number of
  1.2684 +  /// \c true assignments.
  1.2685 +  ///
  1.2686 +  /// Writable bool map that stores for each \c true assigned elements
  1.2687    /// the sequence number of this setting.
  1.2688    /// It makes it easy to calculate the leaving
  1.2689 -  /// order of the nodes in the \c Dfs algorithm.
  1.2690 +  /// order of the nodes in the \ref Dfs algorithm.
  1.2691    ///
  1.2692 -  ///\code
  1.2693 -  /// typedef Digraph::NodeMap<int> OrderMap;
  1.2694 -  /// OrderMap order(digraph);
  1.2695 -  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
  1.2696 -  /// OrderSetterMap setter(order);
  1.2697 -  /// Dfs<Digraph>::DefProcessedMap<OrderSetterMap>::Create dfs(digraph);
  1.2698 -  /// dfs.processedMap(setter);
  1.2699 -  /// dfs.init();
  1.2700 -  /// for (NodeIt it(digraph); it != INVALID; ++it) {
  1.2701 -  ///   if (!dfs.reached(it)) {
  1.2702 -  ///     dfs.addSource(it);
  1.2703 -  ///     dfs.start();
  1.2704 +  /// \code
  1.2705 +  ///   typedef Digraph::NodeMap<int> OrderMap;
  1.2706 +  ///   OrderMap order(digraph);
  1.2707 +  ///   typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
  1.2708 +  ///   OrderSetterMap setter(order);
  1.2709 +  ///   Dfs<Digraph>::DefProcessedMap<OrderSetterMap>::Create dfs(digraph);
  1.2710 +  ///   dfs.processedMap(setter);
  1.2711 +  ///   dfs.init();
  1.2712 +  ///   for (NodeIt it(digraph); it != INVALID; ++it) {
  1.2713 +  ///     if (!dfs.reached(it)) {
  1.2714 +  ///       dfs.addSource(it);
  1.2715 +  ///       dfs.start();
  1.2716 +  ///     }
  1.2717    ///   }
  1.2718 -  /// }
  1.2719 -  ///\endcode
  1.2720 +  /// \endcode
  1.2721    ///
  1.2722    /// The storing of the discovering order is more difficult because the
  1.2723    /// ReachedMap should be readable in the dfs algorithm but the setting
  1.2724    /// order map is not readable. Thus we must use the fork map:
  1.2725    ///
  1.2726 -  ///\code
  1.2727 -  /// typedef Digraph::NodeMap<int> OrderMap;
  1.2728 -  /// OrderMap order(digraph);
  1.2729 -  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
  1.2730 -  /// OrderSetterMap setter(order);
  1.2731 -  /// typedef Digraph::NodeMap<bool> StoreMap;
  1.2732 -  /// StoreMap store(digraph);
  1.2733 +  /// \code
  1.2734 +  ///   typedef Digraph::NodeMap<int> OrderMap;
  1.2735 +  ///   OrderMap order(digraph);
  1.2736 +  ///   typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
  1.2737 +  ///   OrderSetterMap setter(order);
  1.2738 +  ///   typedef Digraph::NodeMap<bool> StoreMap;
  1.2739 +  ///   StoreMap store(digraph);
  1.2740    ///
  1.2741 -  /// typedef ForkWriteMap<StoreMap, OrderSetterMap> ReachedMap;
  1.2742 -  /// ReachedMap reached(store, setter);
  1.2743 +  ///   typedef ForkMap<StoreMap, OrderSetterMap> ReachedMap;
  1.2744 +  ///   ReachedMap reached(store, setter);
  1.2745    ///
  1.2746 -  /// Dfs<Digraph>::DefReachedMap<ReachedMap>::Create dfs(digraph);
  1.2747 -  /// dfs.reachedMap(reached);
  1.2748 -  /// dfs.init();
  1.2749 -  /// for (NodeIt it(digraph); it != INVALID; ++it) {
  1.2750 -  ///   if (!dfs.reached(it)) {
  1.2751 -  ///     dfs.addSource(it);
  1.2752 -  ///     dfs.start();
  1.2753 +  ///   Dfs<Digraph>::DefReachedMap<ReachedMap>::Create dfs(digraph);
  1.2754 +  ///   dfs.reachedMap(reached);
  1.2755 +  ///   dfs.init();
  1.2756 +  ///   for (NodeIt it(digraph); it != INVALID; ++it) {
  1.2757 +  ///     if (!dfs.reached(it)) {
  1.2758 +  ///       dfs.addSource(it);
  1.2759 +  ///       dfs.start();
  1.2760 +  ///     }
  1.2761    ///   }
  1.2762 -  /// }
  1.2763 -  ///\endcode
  1.2764 +  /// \endcode
  1.2765    template <typename Map>
  1.2766    class SettingOrderBoolMap {
  1.2767    public:
  1.2768 @@ -1613,7 +1819,7 @@
  1.2769      typedef bool Value;
  1.2770  
  1.2771      /// Constructor
  1.2772 -    SettingOrderBoolMap(Map& _map) 
  1.2773 +    SettingOrderBoolMap(Map& _map)
  1.2774        : map(_map), counter(0) {}
  1.2775  
  1.2776      /// Number of set operations.
  1.2777 @@ -1621,13 +1827,13 @@
  1.2778        return counter;
  1.2779      }
  1.2780  
  1.2781 -    /// The \c set function of the map
  1.2782 +    /// The set function of the map
  1.2783      void set(const Key& key, Value value) {
  1.2784        if (value) {
  1.2785  	map.set(key, counter++);
  1.2786        }
  1.2787      }
  1.2788 -    
  1.2789 +
  1.2790    private:
  1.2791      Map& map;
  1.2792      int counter;
     2.1 --- a/test/maps_test.cc	Sat Mar 15 20:21:21 2008 +0100
     2.2 +++ b/test/maps_test.cc	Sat Mar 15 21:07:24 2008 +0100
     2.3 @@ -37,72 +37,232 @@
     2.4    typedef A argument_type;
     2.5    typedef B result_type;
     2.6  
     2.7 -  B operator()(const A &) const {return B();}
     2.8 +  B operator()(const A&) const { return B(); }
     2.9 +private:
    2.10 +  F& operator=(const F&);
    2.11  };
    2.12  
    2.13 -int func(A) {return 3;}
    2.14 +int func(A) { return 3; }
    2.15  
    2.16 -int binc(int, B) {return 4;}
    2.17 +int binc(int a, B) { return a+1; }
    2.18  
    2.19 -typedef ReadMap<A,double> DoubleMap;
    2.20 -typedef ReadWriteMap<A, double> WriteDoubleMap;
    2.21 +typedef ReadMap<A, double> DoubleMap;
    2.22 +typedef ReadWriteMap<A, double> DoubleWriteMap;
    2.23 +typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap;
    2.24  
    2.25 -typedef ReadMap<A,bool> BoolMap;
    2.26 +typedef ReadMap<A, bool> BoolMap;
    2.27  typedef ReadWriteMap<A, bool> BoolWriteMap;
    2.28 +typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap;
    2.29  
    2.30  int main()
    2.31 -{ // checking graph components
    2.32 -  
    2.33 +{
    2.34 +  // Map concepts
    2.35    checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
    2.36    checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
    2.37    checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
    2.38    checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
    2.39  
    2.40 -  checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
    2.41 -  checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
    2.42 -  checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
    2.43 -  checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
    2.44 -  checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
    2.45 -  checkConcept<ReadWriteMap<A,double>, NegWriteMap<WriteDoubleMap> >();
    2.46 -  checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
    2.47 -  checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
    2.48 -  checkConcept<ReadWriteMap<A,double>, ShiftWriteMap<WriteDoubleMap> >();
    2.49 -  checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
    2.50 -  checkConcept<ReadWriteMap<A,double>, ScaleWriteMap<WriteDoubleMap> >();
    2.51 -  checkConcept<ReadMap<A,double>, ForkMap<DoubleMap, DoubleMap> >();
    2.52 -  checkConcept<ReadWriteMap<A,double>, 
    2.53 -    ForkWriteMap<WriteDoubleMap, WriteDoubleMap> >();
    2.54 +  // NullMap
    2.55 +  {
    2.56 +    checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
    2.57 +    NullMap<A,B> map1;
    2.58 +    NullMap<A,B> map2 = map1;
    2.59 +    map1 = nullMap<A,B>();
    2.60 +  }
    2.61 +
    2.62 +  // ConstMap
    2.63 +  {
    2.64 +    checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >();
    2.65 +    ConstMap<A,B> map1;
    2.66 +    ConstMap<A,B> map2(B());
    2.67 +    ConstMap<A,B> map3 = map1;
    2.68 +    map1 = constMap<A>(B());
    2.69 +    map1.setAll(B());
    2.70 +    
    2.71 +    checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
    2.72 +    check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
    2.73 +
    2.74 +    checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >();
    2.75 +    ConstMap<A,Const<int,10> > map4;
    2.76 +    ConstMap<A,Const<int,10> > map5 = map4;
    2.77 +    map4 = map5;
    2.78 +    check(map4[A()] == 10 && map5[A()] == 10, "Something is wrong with ConstMap");
    2.79 +  }
    2.80 +
    2.81 +  // IdentityMap
    2.82 +  {
    2.83 +    checkConcept<ReadMap<A,A>, IdentityMap<A> >();
    2.84 +    IdentityMap<A> map1;
    2.85 +    IdentityMap<A> map2 = map1;
    2.86 +    map1 = identityMap<A>();
    2.87 +    
    2.88 +    checkConcept<ReadMap<double,double>, IdentityMap<double> >();
    2.89 +    check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14,
    2.90 +          "Something is wrong with IdentityMap");
    2.91 +  }
    2.92 +
    2.93 +  // RangeMap
    2.94 +  {
    2.95 +    checkConcept<ReferenceMap<int,B,B&,const B&>, RangeMap<B> >();
    2.96 +    RangeMap<B> map1;
    2.97 +    RangeMap<B> map2(10);
    2.98 +    RangeMap<B> map3(10,B());
    2.99 +    RangeMap<B> map4 = map1;
   2.100 +    RangeMap<B> map5 = rangeMap<B>();
   2.101 +    RangeMap<B> map6 = rangeMap<B>(10);
   2.102 +    RangeMap<B> map7 = rangeMap(10,B());
   2.103 +
   2.104 +    checkConcept< ReferenceMap<int, double, double&, const double&>,
   2.105 +                  RangeMap<double> >();
   2.106 +    std::vector<double> v(10, 0);
   2.107 +    v[5] = 100;
   2.108 +    RangeMap<double> map8(v);
   2.109 +    RangeMap<double> map9 = rangeMap(v);
   2.110 +    check(map9.size() == 10 && map9[2] == 0 && map9[5] == 100,
   2.111 +          "Something is wrong with RangeMap");
   2.112 +  }
   2.113 +
   2.114 +  // SparseMap
   2.115 +  {
   2.116 +    checkConcept<ReferenceMap<A,B,B&,const B&>, SparseMap<A,B> >();
   2.117 +    SparseMap<A,B> map1;
   2.118 +    SparseMap<A,B> map2(B());
   2.119 +    SparseMap<A,B> map3 = sparseMap<A,B>();
   2.120 +    SparseMap<A,B> map4 = sparseMap<A>(B());
   2.121 +
   2.122 +    checkConcept< ReferenceMap<double, int, int&, const int&>,
   2.123 +                  SparseMap<double, int> >();
   2.124 +    std::map<double, int> m;
   2.125 +    SparseMap<double, int> map5(m);
   2.126 +    SparseMap<double, int> map6(m,10);
   2.127 +    SparseMap<double, int> map7 = sparseMap(m);
   2.128 +    SparseMap<double, int> map8 = sparseMap(m,10);
   2.129 +
   2.130 +    check(map5[1.0] == 0 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 10,
   2.131 +          "Something is wrong with SparseMap");
   2.132 +    map5[1.0] = map6[3.14] = 100;
   2.133 +    check(map5[1.0] == 100 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 100,
   2.134 +          "Something is wrong with SparseMap");
   2.135 +  }
   2.136 +
   2.137 +  // ComposeMap
   2.138 +  {
   2.139 +    typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
   2.140 +    checkConcept<ReadMap<B,double>, CompMap>();
   2.141 +    CompMap map1(DoubleMap(),ReadMap<B,A>());
   2.142 +    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
   2.143 +    
   2.144 +    SparseMap<double, bool> m1(false); m1[3.14] = true;
   2.145 +    RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
   2.146 +    check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], "Something is wrong with ComposeMap")
   2.147 +  }
   2.148 +
   2.149 +  // CombineMap
   2.150 +  {
   2.151 +    typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
   2.152 +    checkConcept<ReadMap<A,double>, CombMap>();
   2.153 +    CombMap map1(DoubleMap(), DoubleMap());
   2.154 +    CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
   2.155 +
   2.156 +    check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
   2.157 +          "Something is wrong with CombineMap");
   2.158 +  }
   2.159 +
   2.160 +  // FunctorToMap, MapToFunctor
   2.161 +  {
   2.162 +    checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
   2.163 +    checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
   2.164 +    FunctorToMap<F> map1;
   2.165 +    FunctorToMap<F> map2(F());
   2.166 +    B b = functorToMap(F())[A()];
   2.167 +
   2.168 +    checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
   2.169 +    MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>());
   2.170 +
   2.171 +    check(functorToMap(&func)[A()] == 3, "Something is wrong with FunctorToMap");
   2.172 +    check(mapToFunctor(constMap<A,int>(2))(A()) == 2, "Something is wrong with MapToFunctor");
   2.173 +    check(mapToFunctor(functorToMap(&func))(A()) == 3 && mapToFunctor(functorToMap(&func))[A()] == 3,
   2.174 +          "Something is wrong with FunctorToMap or MapToFunctor");
   2.175 +    check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2,
   2.176 +          "Something is wrong with FunctorToMap or MapToFunctor");
   2.177 +  }
   2.178 +
   2.179 +  // ConvertMap
   2.180 +  {
   2.181 +    checkConcept<ReadMap<double,double>, ConvertMap<ReadMap<double, int>, double> >();
   2.182 +    ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true));
   2.183 +    ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false));
   2.184 +  }
   2.185 +
   2.186 +  // ForkMap
   2.187 +  {
   2.188 +    checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
   2.189 +    
   2.190 +    typedef RangeMap<double> RM;
   2.191 +    typedef SparseMap<int, double> SM;
   2.192 +    RM m1(10, -1);
   2.193 +    SM m2(-1);
   2.194 +    checkConcept<ReadWriteMap<int, double>, ForkMap<RM, SM> >();
   2.195 +    checkConcept<ReadWriteMap<int, double>, ForkMap<SM, RM> >();
   2.196 +    ForkMap<RM, SM> map1(m1,m2);
   2.197 +    ForkMap<SM, RM> map2 = forkMap(m2,m1);
   2.198 +    map2.set(5, 10);
   2.199 +    check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && m2[5] == 10 && map2[1] == -1 && map2[5] == 10,
   2.200 +          "Something is wrong with ForkMap");
   2.201 +  }
   2.202    
   2.203 -  checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
   2.204 +  // Arithmetic maps:
   2.205 +  // - AddMap, SubMap, MulMap, DivMap
   2.206 +  // - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap
   2.207 +  // - NegMap, NegWriteMap, AbsMap
   2.208 +  {
   2.209 +    checkConcept<DoubleMap, AddMap<DoubleMap,DoubleMap> >();
   2.210 +    checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >();
   2.211 +    checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
   2.212 +    checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
   2.213 +    
   2.214 +    ConstMap<int, double> c1(1.0), c2(3.14);
   2.215 +    IdentityMap<int> im;
   2.216 +    ConvertMap<IdentityMap<int>, double> id(im);
   2.217 +    check(addMap(c1,id)[0] == 1.0  && addMap(c1,id)[10] == 11.0, "Something is wrong with AddMap");
   2.218 +    check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0,  "Something is wrong with SubMap");
   2.219 +    check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28, "Something is wrong with MulMap");
   2.220 +    check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57, "Something is wrong with DivMap");
   2.221 +    
   2.222 +    checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
   2.223 +    checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
   2.224 +    checkConcept<DoubleMap, ScaleMap<DoubleMap> >();
   2.225 +    checkConcept<DoubleWriteMap, ScaleWriteMap<DoubleWriteMap> >();
   2.226 +    checkConcept<DoubleMap, NegMap<DoubleMap> >();
   2.227 +    checkConcept<DoubleWriteMap, NegWriteMap<DoubleWriteMap> >();
   2.228 +    checkConcept<DoubleMap, AbsMap<DoubleMap> >();
   2.229  
   2.230 -  checkConcept<ReadMap<A,B>, FunctorMap<F, A, B> >();
   2.231 +    check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0,
   2.232 +          "Something is wrong with ShiftMap");
   2.233 +    check(shiftWriteMap(id, 2.0)[1] == 3.0 && shiftWriteMap(id, 2.0)[10] == 12.0,
   2.234 +          "Something is wrong with ShiftWriteMap");
   2.235 +    check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0,
   2.236 +          "Something is wrong with ScaleMap");
   2.237 +    check(scaleWriteMap(id, 2.0)[1] == 2.0 && scaleWriteMap(id, 2.0)[10] == 20.0,
   2.238 +          "Something is wrong with ScaleWriteMap");
   2.239 +    check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0,
   2.240 +          "Something is wrong with NegMap");
   2.241 +    check(negWriteMap(id)[1] == -1.0 && negWriteMap(id)[-10] == 10.0,
   2.242 +          "Something is wrong with NegWriteMap");
   2.243 +    check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0,
   2.244 +          "Something is wrong with AbsMap");
   2.245 +  }
   2.246 +  
   2.247 +  // Logical maps
   2.248 +  {
   2.249 +    checkConcept<BoolMap, NotMap<BoolMap> >();
   2.250 +    checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
   2.251 +    
   2.252 +    RangeMap<bool> rm(2);
   2.253 +    rm[0] = true; rm[1] = false;
   2.254 +    check(!(notMap(rm)[0]) && notMap(rm)[1], "Something is wrong with NotMap");
   2.255 +    check(!(notWriteMap(rm)[0]) && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
   2.256 +  }
   2.257  
   2.258 -  checkConcept<ReadMap<A, bool>, NotMap<BoolMap> >();
   2.259 -  checkConcept<ReadWriteMap<A, bool>, NotWriteMap<BoolWriteMap> >();
   2.260 -
   2.261 -  checkConcept<WriteMap<A, bool>, StoreBoolMap<A*> >();
   2.262 -  checkConcept<WriteMap<A, bool>, BackInserterBoolMap<std::deque<A> > >();
   2.263 -  checkConcept<WriteMap<A, bool>, FrontInserterBoolMap<std::deque<A> > >();
   2.264 -  checkConcept<WriteMap<A, bool>, InserterBoolMap<std::set<A> > >();
   2.265 -  checkConcept<WriteMap<A, bool>, FillBoolMap<WriteMap<A, B> > >();
   2.266 -  checkConcept<WriteMap<A, bool>, SettingOrderBoolMap<WriteMap<A, int> > >();
   2.267 -
   2.268 -  int a;
   2.269 -  
   2.270 -  a=mapFunctor(constMap<A,int>(2))(A());
   2.271 -  check(a==2,"Something is wrong with mapFunctor");
   2.272 -
   2.273 -  B b;
   2.274 -  b=functorMap(F())[A()];
   2.275 -
   2.276 -  a=functorMap(&func)[A()];
   2.277 -  check(a==3,"Something is wrong with functorMap");
   2.278 -
   2.279 -  a=combineMap(constMap<B, int, 1>(), identityMap<B>(), &binc)[B()];
   2.280 -  check(a==4,"Something is wrong with combineMap");
   2.281 -  
   2.282 -
   2.283 -  std::cout << __FILE__ ": All tests passed.\n";
   2.284 -  
   2.285    return 0;
   2.286  }