Merge
authorAlpar Juttner <alpar@cs.elte.hu>
Sun, 16 Mar 2008 07:32:43 +0000
changeset 848161012eaa61
parent 78 c46b3453455f
parent 83 3654324ec035
child 89 e6452a49192c
Merge
     1.1 --- a/doc/groups.dox	Thu Feb 28 17:06:02 2008 +0100
     1.2 +++ b/doc/groups.dox	Sun Mar 16 07:32:43 2008 +0000
     1.3 @@ -38,13 +38,13 @@
     1.4  accessed.  LEMON provides several physical graph structures to meet
     1.5  the diverging requirements of the possible users.  In order to save on
     1.6  running time or on memory usage, some structures may fail to provide
     1.7 -some graph features like edge or node deletion.
     1.8 +some graph features like arc/edge or node deletion.
     1.9  
    1.10  Alteration of standard containers need a very limited number of 
    1.11  operations, these together satisfy the everyday requirements. 
    1.12  In the case of graph structures, different operations are needed which do 
    1.13  not alter the physical graph, but gives another view. If some nodes or 
    1.14 -edges have to be hidden or the reverse oriented graph have to be used, then 
    1.15 +arcs have to be hidden or the reverse oriented graph have to be used, then
    1.16  this is the case. It also may happen that in a flow implementation 
    1.17  the residual graph can be accessed by another algorithm, or a node-set 
    1.18  is to be shrunk for another algorithm. 
    1.19 @@ -81,10 +81,10 @@
    1.20  /**
    1.21  @defgroup graph_maps Graph Maps 
    1.22  @ingroup maps
    1.23 -\brief Special Graph-Related Maps.
    1.24 +\brief Special graph-related maps.
    1.25  
    1.26  This group describes maps that are specifically designed to assign
    1.27 -values to the nodes and edges of graphs.
    1.28 +values to the nodes and arcs of graphs.
    1.29  */
    1.30  
    1.31  
    1.32 @@ -96,15 +96,15 @@
    1.33  This group describes map adaptors that are used to create "implicit"
    1.34  maps from other maps.
    1.35  
    1.36 -Most of them are \ref lemon::concepts::ReadMap "ReadMap"s. They can
    1.37 -make arithmetic operations between one or two maps (negation, scaling,
    1.38 -addition, multiplication etc.) or e.g. convert a map to another one
    1.39 -of different Value type.
    1.40 +Most of them are \ref lemon::concepts::ReadMap "read-only maps".
    1.41 +They can make arithmetic and logical operations between one or two maps
    1.42 +(negation, shifting, addition, multiplication, logical 'and', 'or',
    1.43 +'not' etc.) or e.g. convert a map to another one of different Value type.
    1.44  
    1.45  The typical usage of this classes is passing implicit maps to
    1.46  algorithms.  If a function type algorithm is called then the function
    1.47  type map adaptors can be used comfortable. For example let's see the
    1.48 -usage of map adaptors with the \c graphToEps() function:
    1.49 +usage of map adaptors with the \c digraphToEps() function.
    1.50  \code
    1.51    Color nodeColor(int deg) {
    1.52      if (deg >= 2) {
    1.53 @@ -116,39 +116,37 @@
    1.54      }
    1.55    }
    1.56    
    1.57 -  Graph::NodeMap<int> degree_map(graph);
    1.58 +  Digraph::NodeMap<int> degree_map(graph);
    1.59    
    1.60 -  graphToEps(graph, "graph.eps")
    1.61 +  digraphToEps(graph, "graph.eps")
    1.62      .coords(coords).scaleToA4().undirected()
    1.63 -    .nodeColors(composeMap(functorMap(nodeColor), degree_map)) 
    1.64 +    .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
    1.65      .run();
    1.66  \endcode 
    1.67 -The \c functorMap() function makes an \c int to \c Color map from the
    1.68 +The \c functorToMap() function makes an \c int to \c Color map from the
    1.69  \e nodeColor() function. The \c composeMap() compose the \e degree_map
    1.70 -and the previous created map. The composed map is proper function to
    1.71 -get color of each node.
    1.72 +and the previously created map. The composed map is a proper function to
    1.73 +get the color of each node.
    1.74  
    1.75  The usage with class type algorithms is little bit harder. In this
    1.76  case the function type map adaptors can not be used, because the
    1.77  function map adaptors give back temporary objects.
    1.78  \code
    1.79 -  Graph graph;
    1.80 -  
    1.81 -  typedef Graph::EdgeMap<double> DoubleEdgeMap;
    1.82 -  DoubleEdgeMap length(graph);
    1.83 -  DoubleEdgeMap speed(graph);
    1.84 -  
    1.85 -  typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap;
    1.86 -  
    1.87 +  Digraph graph;
    1.88 +
    1.89 +  typedef Digraph::ArcMap<double> DoubleArcMap;
    1.90 +  DoubleArcMap length(graph);
    1.91 +  DoubleArcMap speed(graph);
    1.92 +
    1.93 +  typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
    1.94    TimeMap time(length, speed);
    1.95    
    1.96 -  Dijkstra<Graph, TimeMap> dijkstra(graph, time);
    1.97 +  Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
    1.98    dijkstra.run(source, target);
    1.99  \endcode
   1.100 -
   1.101 -We have a length map and a maximum speed map on a graph. The minimum
   1.102 -time to pass the edge can be calculated as the division of the two
   1.103 -maps which can be done implicitly with the \c DivMap template
   1.104 +We have a length map and a maximum speed map on the arcs of a digraph.
   1.105 +The minimum time to pass the arc can be calculated as the division of
   1.106 +the two maps which can be done implicitly with the \c DivMap template
   1.107  class. We use the implicit minimum time map as the length map of the
   1.108  \c Dijkstra algorithm.
   1.109  */
   1.110 @@ -315,7 +313,7 @@
   1.111  
   1.112  This group contains algorithm objects and functions to calculate
   1.113  matchings in graphs and bipartite graphs. The general matching problem is
   1.114 -finding a subset of the edges which does not shares common endpoints.
   1.115 +finding a subset of the arcs which does not shares common endpoints.
   1.116   
   1.117  There are several different algorithms for calculate matchings in
   1.118  graphs.  The matching problems in bipartite graphs are generally
     2.1 --- a/lemon/concepts/maps.h	Thu Feb 28 17:06:02 2008 +0100
     2.2 +++ b/lemon/concepts/maps.h	Sun Mar 16 07:32:43 2008 +0000
     2.3 @@ -29,7 +29,7 @@
     2.4  namespace lemon {
     2.5  
     2.6    namespace concepts {
     2.7 -  
     2.8 +
     2.9      /// \addtogroup concept
    2.10      /// @{
    2.11  
    2.12 @@ -42,39 +42,39 @@
    2.13      {
    2.14      public:
    2.15        /// The key type of the map.
    2.16 -      typedef K Key;    
    2.17 +      typedef K Key;
    2.18        /// The value type of the map. (The type of objects associated with the keys).
    2.19        typedef T Value;
    2.20  
    2.21 -      /// Returns the value associated with a key.
    2.22 +      /// Returns the value associated with the given key.
    2.23  
    2.24 -      /// Returns the value associated with a key.
    2.25 -      /// \bug Value shouldn't need to be default constructible.
    2.26 -      ///
    2.27 -      Value operator[](const Key &) const {return Value();}
    2.28 +      /// Returns the value associated with the given key.
    2.29 +      /// \bug Value shouldn't need to be default constructible. 
    2.30 +      Value operator[](const Key &) const { return Value(); }
    2.31  
    2.32        template<typename _ReadMap>
    2.33        struct Constraints {
    2.34  	void constraints() {
    2.35  	  Value val = m[key];
    2.36  	  val = m[key];
    2.37 -	  typename _ReadMap::Value own_val = m[own_key]; 
    2.38 -	  own_val = m[own_key]; 
    2.39 +	  typename _ReadMap::Value own_val = m[own_key];
    2.40 +	  own_val = m[own_key];
    2.41  
    2.42 +	  ignore_unused_variable_warning(key);
    2.43  	  ignore_unused_variable_warning(val);
    2.44 +	  ignore_unused_variable_warning(own_key);
    2.45  	  ignore_unused_variable_warning(own_val);
    2.46 -	  ignore_unused_variable_warning(key);
    2.47  	}
    2.48 -	Key& key;
    2.49 -	typename _ReadMap::Key& own_key;
    2.50 -	_ReadMap& m;
    2.51 +	const Key& key;
    2.52 +	const typename _ReadMap::Key& own_key;
    2.53 +	const _ReadMap& m;
    2.54        };
    2.55 -      
    2.56 +
    2.57      };
    2.58  
    2.59  
    2.60      /// Writable map concept
    2.61 -    
    2.62 +
    2.63      /// Writable map concept.
    2.64      ///
    2.65      template<typename K, typename T>
    2.66 @@ -82,39 +82,37 @@
    2.67      {
    2.68      public:
    2.69        /// The key type of the map.
    2.70 -      typedef K Key;    
    2.71 +      typedef K Key;
    2.72        /// The value type of the map. (The type of objects associated with the keys).
    2.73        typedef T Value;
    2.74  
    2.75 -      /// Sets the value associated with a key.
    2.76 -      void set(const Key &,const Value &) {}
    2.77 +      /// Sets the value associated with the given key.
    2.78 +      void set(const Key &, const Value &) {}
    2.79  
    2.80 -      ///Default constructor
    2.81 +      /// Default constructor.
    2.82        WriteMap() {}
    2.83  
    2.84        template <typename _WriteMap>
    2.85        struct Constraints {
    2.86  	void constraints() {
    2.87 -	  // No constraints for constructor.
    2.88  	  m.set(key, val);
    2.89  	  m.set(own_key, own_val);
    2.90 +
    2.91  	  ignore_unused_variable_warning(key);
    2.92  	  ignore_unused_variable_warning(val);
    2.93  	  ignore_unused_variable_warning(own_key);
    2.94  	  ignore_unused_variable_warning(own_val);
    2.95  	}
    2.96 -
    2.97 -	Value& val;
    2.98 -	typename _WriteMap::Value own_val;
    2.99 -	Key& key;
   2.100 -	typename _WriteMap::Key& own_key;
   2.101 +	const Key& key;
   2.102 +	const Value& val;
   2.103 +	const typename _WriteMap::Key& own_key;
   2.104 +	const typename _WriteMap::Value own_val;
   2.105  	_WriteMap& m;
   2.106 -
   2.107        };
   2.108      };
   2.109  
   2.110      /// Read/writable map concept
   2.111 -    
   2.112 +
   2.113      /// Read/writable map concept.
   2.114      ///
   2.115      template<typename K, typename T>
   2.116 @@ -123,14 +121,15 @@
   2.117      {
   2.118      public:
   2.119        /// The key type of the map.
   2.120 -      typedef K Key;    
   2.121 +      typedef K Key;
   2.122        /// The value type of the map. (The type of objects associated with the keys).
   2.123        typedef T Value;
   2.124  
   2.125 -      /// Returns the value associated with a key.
   2.126 -      Value operator[](const Key &) const {return Value();}
   2.127 -      /// Sets the value associated with a key.
   2.128 -      void set(const Key & ,const Value &) {}
   2.129 +      /// Returns the value associated with the given key.
   2.130 +      Value operator[](const Key &) const { return Value(); }
   2.131 +
   2.132 +      /// Sets the value associated with the given key.
   2.133 +      void set(const Key &, const Value &) {}
   2.134  
   2.135        template<typename _ReadWriteMap>
   2.136        struct Constraints {
   2.137 @@ -140,13 +139,12 @@
   2.138  	}
   2.139        };
   2.140      };
   2.141 -  
   2.142 -  
   2.143 +
   2.144 +
   2.145      /// Dereferable map concept
   2.146 -    
   2.147 +
   2.148      /// Dereferable map concept.
   2.149      ///
   2.150 -    /// \todo Rethink this concept.
   2.151      template<typename K, typename T, typename R, typename CR>
   2.152      class ReferenceMap : public ReadWriteMap<K,T>
   2.153      {
   2.154 @@ -154,7 +152,7 @@
   2.155        /// Tag for reference maps.
   2.156        typedef True ReferenceMapTag;
   2.157        /// The key type of the map.
   2.158 -      typedef K Key;    
   2.159 +      typedef K Key;
   2.160        /// The value type of the map. (The type of objects associated with the keys).
   2.161        typedef T Value;
   2.162        /// The reference type of the map.
   2.163 @@ -166,33 +164,38 @@
   2.164        Value tmp;
   2.165      public:
   2.166  
   2.167 -      ///Returns a reference to the value associated with a key.
   2.168 +      /// Returns a reference to the value associated with the given key.
   2.169        Reference operator[](const Key &) { return tmp; }
   2.170 -      ///Returns a const reference to the value associated with a key.
   2.171 +
   2.172 +      /// Returns a const reference to the value associated with the given key.
   2.173        ConstReference operator[](const Key &) const { return tmp; }
   2.174 -      /// Sets the value associated with a key.
   2.175 +
   2.176 +      /// Sets the value associated with the given key.
   2.177        void set(const Key &k,const Value &t) { operator[](k)=t; }
   2.178  
   2.179        template<typename _ReferenceMap>
   2.180        struct Constraints {
   2.181  	void constraints() {
   2.182  	  checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
   2.183 +	  ref = m[key];
   2.184  	  m[key] = val;
   2.185 -	  val  = m[key];
   2.186  	  m[key] = ref;
   2.187 -	  ref = m[key];
   2.188 +	  m[key] = cref;
   2.189 +	  own_ref = m[own_key];
   2.190  	  m[own_key] = own_val;
   2.191 -	  own_val  = m[own_key];
   2.192  	  m[own_key] = own_ref;
   2.193 -	  own_ref = m[own_key];	  	  
   2.194 +	  m[own_key] = own_cref;
   2.195 +	  m[key] = m[own_key];
   2.196 +	  m[own_key] = m[key];
   2.197  	}
   2.198 -
   2.199 -	typename _ReferenceMap::Key& own_key;
   2.200 +	const Key& key;
   2.201 +	Value& val;
   2.202 +	Reference ref;
   2.203 +	ConstReference cref;
   2.204 +	const typename _ReferenceMap::Key& own_key;
   2.205  	typename _ReferenceMap::Value& own_val;
   2.206  	typename _ReferenceMap::Reference own_ref;
   2.207 -	Key& key;
   2.208 -	Value& val;
   2.209 -	Reference ref;
   2.210 +	typename _ReferenceMap::ConstReference own_cref;
   2.211  	_ReferenceMap& m;
   2.212        };
   2.213      };
     3.1 --- a/lemon/maps.h	Thu Feb 28 17:06:02 2008 +0100
     3.2 +++ b/lemon/maps.h	Sun Mar 16 07:32:43 2008 +0000
     3.3 @@ -24,12 +24,12 @@
     3.4  #include <vector>
     3.5  
     3.6  #include <lemon/bits/utility.h>
     3.7 -// #include <lemon/bits/traits.h>
     3.8 +#include <lemon/bits/traits.h>
     3.9  
    3.10  ///\file
    3.11  ///\ingroup maps
    3.12  ///\brief Miscellaneous property maps
    3.13 -///
    3.14 +
    3.15  #include <map>
    3.16  
    3.17  namespace lemon {
    3.18 @@ -39,41 +39,46 @@
    3.19  
    3.20    /// Base class of maps.
    3.21  
    3.22 -  /// Base class of maps.
    3.23 -  /// It provides the necessary <tt>typedef</tt>s required by the map concept.
    3.24 -  template<typename K, typename T>
    3.25 +  /// Base class of maps. It provides the necessary type definitions
    3.26 +  /// required by the map %concepts.
    3.27 +  template<typename K, typename V>
    3.28    class MapBase {
    3.29    public:
    3.30 -    /// The key type of the map.
    3.31 +    /// \biref The key type of the map.
    3.32      typedef K Key;
    3.33 -    /// The value type of the map. (The type of objects associated with the keys).
    3.34 -    typedef T Value;
    3.35 +    /// \brief The value type of the map.
    3.36 +    /// (The type of objects associated with the keys).
    3.37 +    typedef V Value;
    3.38    };
    3.39  
    3.40 +
    3.41    /// Null map. (a.k.a. DoNothingMap)
    3.42  
    3.43    /// This map can be used if you have to provide a map only for
    3.44 -  /// its type definitions, or if you have to provide a writable map, 
    3.45 -  /// but data written to it is not required (i.e. it will be sent to 
    3.46 +  /// its type definitions, or if you have to provide a writable map,
    3.47 +  /// but data written to it is not required (i.e. it will be sent to
    3.48    /// <tt>/dev/null</tt>).
    3.49 -  template<typename K, typename T>
    3.50 -  class NullMap : public MapBase<K, T> {
    3.51 +  /// It conforms the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    3.52 +  ///
    3.53 +  /// \sa ConstMap
    3.54 +  template<typename K, typename V>
    3.55 +  class NullMap : public MapBase<K, V> {
    3.56    public:
    3.57 -    typedef MapBase<K, T> Parent;
    3.58 +    typedef MapBase<K, V> Parent;
    3.59      typedef typename Parent::Key Key;
    3.60      typedef typename Parent::Value Value;
    3.61 -    
    3.62 +
    3.63      /// Gives back a default constructed element.
    3.64 -    T operator[](const K&) const { return T(); }
    3.65 +    Value operator[](const Key&) const { return Value(); }
    3.66      /// Absorbs the value.
    3.67 -    void set(const K&, const T&) {}
    3.68 +    void set(const Key&, const Value&) {}
    3.69    };
    3.70  
    3.71 -  ///Returns a \c NullMap class
    3.72 +  /// Returns a \ref NullMap class
    3.73  
    3.74 -  ///This function just returns a \c NullMap class.
    3.75 -  ///\relates NullMap
    3.76 -  template <typename K, typename V> 
    3.77 +  /// This function just returns a \ref NullMap class.
    3.78 +  /// \relates NullMap
    3.79 +  template <typename K, typename V>
    3.80    NullMap<K, V> nullMap() {
    3.81      return NullMap<K, V>();
    3.82    }
    3.83 @@ -81,62 +86,81 @@
    3.84  
    3.85    /// Constant map.
    3.86  
    3.87 -  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
    3.88 -  /// specified value to each key.
    3.89 -  /// In other aspects it is equivalent to \c NullMap.
    3.90 -  template<typename K, typename T>
    3.91 -  class ConstMap : public MapBase<K, T> {
    3.92 +  /// This \ref concepts::ReadMap "readable map" assigns a specified
    3.93 +  /// value to each key.
    3.94 +  ///
    3.95 +  /// In other aspects it is equivalent to \ref NullMap.
    3.96 +  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
    3.97 +  /// concept, but it absorbs the data written to it.
    3.98 +  ///
    3.99 +  /// The simplest way of using this map is through the constMap()
   3.100 +  /// function.
   3.101 +  ///
   3.102 +  /// \sa NullMap
   3.103 +  /// \sa IdentityMap
   3.104 +  template<typename K, typename V>
   3.105 +  class ConstMap : public MapBase<K, V> {
   3.106    private:
   3.107 -    T v;
   3.108 +    V _value;
   3.109    public:
   3.110 -
   3.111 -    typedef MapBase<K, T> Parent;
   3.112 +    typedef MapBase<K, V> Parent;
   3.113      typedef typename Parent::Key Key;
   3.114      typedef typename Parent::Value Value;
   3.115  
   3.116      /// Default constructor
   3.117  
   3.118      /// Default constructor.
   3.119 -    /// The value of the map will be uninitialized. 
   3.120 -    /// (More exactly it will be default constructed.)
   3.121 +    /// The value of the map will be default constructed.
   3.122      ConstMap() {}
   3.123 -    
   3.124 +
   3.125      /// Constructor with specified initial value
   3.126  
   3.127      /// Constructor with specified initial value.
   3.128 -    /// \param _v is the initial value of the map.
   3.129 -    ConstMap(const T &_v) : v(_v) {}
   3.130 -    
   3.131 -    ///\e
   3.132 -    T operator[](const K&) const { return v; }
   3.133 +    /// \param v is the initial value of the map.
   3.134 +    ConstMap(const Value &v) : _value(v) {}
   3.135  
   3.136 -    ///\e
   3.137 -    void setAll(const T &t) {
   3.138 -      v = t;
   3.139 -    }    
   3.140 +    /// Gives back the specified value.
   3.141 +    Value operator[](const Key&) const { return _value; }
   3.142  
   3.143 -    template<typename T1>
   3.144 -    ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
   3.145 +    /// Absorbs the value.
   3.146 +    void set(const Key&, const Value&) {}
   3.147 +
   3.148 +    /// Sets the value that is assigned to each key.
   3.149 +    void setAll(const Value &v) {
   3.150 +      _value = v;
   3.151 +    }
   3.152 +
   3.153 +    template<typename V1>
   3.154 +    ConstMap(const ConstMap<K, V1> &, const Value &v) : _value(v) {}
   3.155    };
   3.156  
   3.157 -  ///Returns a \c ConstMap class
   3.158 +  /// Returns a \ref ConstMap class
   3.159  
   3.160 -  ///This function just returns a \c ConstMap class.
   3.161 -  ///\relates ConstMap
   3.162 -  template<typename K, typename V> 
   3.163 +  /// This function just returns a \ref ConstMap class.
   3.164 +  /// \relates ConstMap
   3.165 +  template<typename K, typename V>
   3.166    inline ConstMap<K, V> constMap(const V &v) {
   3.167      return ConstMap<K, V>(v);
   3.168    }
   3.169  
   3.170  
   3.171    template<typename T, T v>
   3.172 -  struct Const { };
   3.173 +  struct Const {};
   3.174  
   3.175    /// Constant map with inlined constant value.
   3.176  
   3.177 -  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
   3.178 -  /// specified value to each key.
   3.179 -  /// In other aspects it is equivalent to \c NullMap.
   3.180 +  /// This \ref concepts::ReadMap "readable map" assigns a specified
   3.181 +  /// value to each key.
   3.182 +  ///
   3.183 +  /// In other aspects it is equivalent to \ref NullMap.
   3.184 +  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
   3.185 +  /// concept, but it absorbs the data written to it.
   3.186 +  ///
   3.187 +  /// The simplest way of using this map is through the constMap()
   3.188 +  /// function.
   3.189 +  ///
   3.190 +  /// \sa NullMap
   3.191 +  /// \sa IdentityMap
   3.192    template<typename K, typename V, V v>
   3.193    class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
   3.194    public:
   3.195 @@ -144,69 +168,230 @@
   3.196      typedef typename Parent::Key Key;
   3.197      typedef typename Parent::Value Value;
   3.198  
   3.199 -    ConstMap() { }
   3.200 -    ///\e
   3.201 -    V operator[](const K&) const { return v; }
   3.202 -    ///\e
   3.203 -    void set(const K&, const V&) { }
   3.204 +    /// Constructor.
   3.205 +    ConstMap() {}
   3.206 +
   3.207 +    /// Gives back the specified value.
   3.208 +    Value operator[](const Key&) const { return v; }
   3.209 +
   3.210 +    /// Absorbs the value.
   3.211 +    void set(const Key&, const Value&) {}
   3.212    };
   3.213  
   3.214 -  ///Returns a \c ConstMap class with inlined value
   3.215 +  /// Returns a \ref ConstMap class with inlined constant value
   3.216  
   3.217 -  ///This function just returns a \c ConstMap class with inlined value.
   3.218 -  ///\relates ConstMap
   3.219 -  template<typename K, typename V, V v> 
   3.220 +  /// This function just returns a \ref ConstMap class with inlined
   3.221 +  /// constant value.
   3.222 +  /// \relates ConstMap
   3.223 +  template<typename K, typename V, V v>
   3.224    inline ConstMap<K, Const<V, v> > constMap() {
   3.225      return ConstMap<K, Const<V, v> >();
   3.226    }
   3.227  
   3.228 -  ///Map based on \c std::map
   3.229  
   3.230 -  ///This is essentially a wrapper for \c std::map with addition that
   3.231 -  ///you can specify a default value different from \c Value().
   3.232 -  ///It meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
   3.233 -  template <typename K, typename T, typename Compare = std::less<K> >
   3.234 -  class StdMap : public MapBase<K, T> {
   3.235 -    template <typename K1, typename T1, typename C1>
   3.236 -    friend class StdMap;
   3.237 +  /// Identity map.
   3.238 +
   3.239 +  /// This \ref concepts::ReadMap "read-only map" gives back the given
   3.240 +  /// key as value without any modification.
   3.241 +  ///
   3.242 +  /// \sa ConstMap
   3.243 +  template <typename T>
   3.244 +  class IdentityMap : public MapBase<T, T> {
   3.245 +  public:
   3.246 +    typedef MapBase<T, T> Parent;
   3.247 +    typedef typename Parent::Key Key;
   3.248 +    typedef typename Parent::Value Value;
   3.249 +
   3.250 +    /// Gives back the given value without any modification.
   3.251 +    Value operator[](const Key &k) const {
   3.252 +      return k;
   3.253 +    }
   3.254 +  };
   3.255 +
   3.256 +  /// Returns an \ref IdentityMap class
   3.257 +
   3.258 +  /// This function just returns an \ref IdentityMap class.
   3.259 +  /// \relates IdentityMap
   3.260 +  template<typename T>
   3.261 +  inline IdentityMap<T> identityMap() {
   3.262 +    return IdentityMap<T>();
   3.263 +  }
   3.264 +
   3.265 +
   3.266 +  /// \brief Map for storing values for integer keys from the range
   3.267 +  /// <tt>[0..size-1]</tt>.
   3.268 +  ///
   3.269 +  /// This map is essentially a wrapper for \c std::vector. It assigns
   3.270 +  /// values to integer keys from the range <tt>[0..size-1]</tt>.
   3.271 +  /// It can be used with some data structures, for example
   3.272 +  /// \ref UnionFind, \ref BinHeap, when the used items are small
   3.273 +  /// integers. This map conforms the \ref concepts::ReferenceMap
   3.274 +  /// "ReferenceMap" concept.
   3.275 +  ///
   3.276 +  /// The simplest way of using this map is through the rangeMap()
   3.277 +  /// function.
   3.278 +  template <typename V>
   3.279 +  class RangeMap : public MapBase<int, V> {
   3.280 +    template <typename V1>
   3.281 +    friend class RangeMap;
   3.282 +  private:
   3.283 +
   3.284 +    typedef std::vector<V> Vector;
   3.285 +    Vector _vector;
   3.286 +
   3.287    public:
   3.288  
   3.289 -    typedef MapBase<K, T> Parent;
   3.290 -    ///Key type
   3.291 +    typedef MapBase<int, V> Parent;
   3.292 +    /// Key type
   3.293      typedef typename Parent::Key Key;
   3.294 -    ///Value type
   3.295 +    /// Value type
   3.296      typedef typename Parent::Value Value;
   3.297 -    ///Reference Type
   3.298 -    typedef T& Reference;
   3.299 -    ///Const reference type
   3.300 -    typedef const T& ConstReference;
   3.301 +    /// Reference type
   3.302 +    typedef typename Vector::reference Reference;
   3.303 +    /// Const reference type
   3.304 +    typedef typename Vector::const_reference ConstReference;
   3.305 +
   3.306 +    typedef True ReferenceMapTag;
   3.307 +
   3.308 +  public:
   3.309 +
   3.310 +    /// Constructor with specified default value.
   3.311 +    RangeMap(int size = 0, const Value &value = Value())
   3.312 +      : _vector(size, value) {}
   3.313 +
   3.314 +    /// Constructs the map from an appropriate \c std::vector.
   3.315 +    template <typename V1>
   3.316 +    RangeMap(const std::vector<V1>& vector)
   3.317 +      : _vector(vector.begin(), vector.end()) {}
   3.318 +
   3.319 +    /// Constructs the map from another \ref RangeMap.
   3.320 +    template <typename V1>
   3.321 +    RangeMap(const RangeMap<V1> &c)
   3.322 +      : _vector(c._vector.begin(), c._vector.end()) {}
   3.323 +
   3.324 +    /// Returns the size of the map.
   3.325 +    int size() {
   3.326 +      return _vector.size();
   3.327 +    }
   3.328 +
   3.329 +    /// Resizes the map.
   3.330 +
   3.331 +    /// Resizes the underlying \c std::vector container, so changes the
   3.332 +    /// keyset of the map.
   3.333 +    /// \param size The new size of the map. The new keyset will be the
   3.334 +    /// range <tt>[0..size-1]</tt>.
   3.335 +    /// \param value The default value to assign to the new keys.
   3.336 +    void resize(int size, const Value &value = Value()) {
   3.337 +      _vector.resize(size, value);
   3.338 +    }
   3.339 +
   3.340 +  private:
   3.341 +
   3.342 +    RangeMap& operator=(const RangeMap&);
   3.343 +
   3.344 +  public:
   3.345 +
   3.346 +    ///\e
   3.347 +    Reference operator[](const Key &k) {
   3.348 +      return _vector[k];
   3.349 +    }
   3.350 +
   3.351 +    ///\e
   3.352 +    ConstReference operator[](const Key &k) const {
   3.353 +      return _vector[k];
   3.354 +    }
   3.355 +
   3.356 +    ///\e
   3.357 +    void set(const Key &k, const Value &v) {
   3.358 +      _vector[k] = v;
   3.359 +    }
   3.360 +  };
   3.361 +
   3.362 +  /// Returns a \ref RangeMap class
   3.363 +
   3.364 +  /// This function just returns a \ref RangeMap class.
   3.365 +  /// \relates RangeMap
   3.366 +  template<typename V>
   3.367 +  inline RangeMap<V> rangeMap(int size = 0, const V &value = V()) {
   3.368 +    return RangeMap<V>(size, value);
   3.369 +  }
   3.370 +
   3.371 +  /// \brief Returns a \ref RangeMap class created from an appropriate
   3.372 +  /// \c std::vector
   3.373 +
   3.374 +  /// This function just returns a \ref RangeMap class created from an
   3.375 +  /// appropriate \c std::vector.
   3.376 +  /// \relates RangeMap
   3.377 +  template<typename V>
   3.378 +  inline RangeMap<V> rangeMap(const std::vector<V> &vector) {
   3.379 +    return RangeMap<V>(vector);
   3.380 +  }
   3.381 +
   3.382 +
   3.383 +  /// Map type based on \c std::map
   3.384 +
   3.385 +  /// This map is essentially a wrapper for \c std::map with addition
   3.386 +  /// that you can specify a default value for the keys that are not
   3.387 +  /// stored actually. This value can be different from the default
   3.388 +  /// contructed value (i.e. \c %Value()).
   3.389 +  /// This type conforms the \ref concepts::ReferenceMap "ReferenceMap"
   3.390 +  /// concept.
   3.391 +  ///
   3.392 +  /// This map is useful if a default value should be assigned to most of
   3.393 +  /// the keys and different values should be assigned only to a few
   3.394 +  /// keys (i.e. the map is "sparse").
   3.395 +  /// The name of this type also refers to this important usage.
   3.396 +  ///
   3.397 +  /// Apart form that this map can be used in many other cases since it
   3.398 +  /// is based on \c std::map, which is a general associative container.
   3.399 +  /// However keep in mind that it is usually not as efficient as other
   3.400 +  /// maps.
   3.401 +  ///
   3.402 +  /// The simplest way of using this map is through the sparseMap()
   3.403 +  /// function.
   3.404 +  template <typename K, typename V, typename Compare = std::less<K> >
   3.405 +  class SparseMap : public MapBase<K, V> {
   3.406 +    template <typename K1, typename V1, typename C1>
   3.407 +    friend class SparseMap;
   3.408 +  public:
   3.409 +
   3.410 +    typedef MapBase<K, V> Parent;
   3.411 +    /// Key type
   3.412 +    typedef typename Parent::Key Key;
   3.413 +    /// Value type
   3.414 +    typedef typename Parent::Value Value;
   3.415 +    /// Reference type
   3.416 +    typedef Value& Reference;
   3.417 +    /// Const reference type
   3.418 +    typedef const Value& ConstReference;
   3.419  
   3.420      typedef True ReferenceMapTag;
   3.421  
   3.422    private:
   3.423 -    
   3.424 -    typedef std::map<K, T, Compare> Map;
   3.425 +
   3.426 +    typedef std::map<K, V, Compare> Map;
   3.427 +    Map _map;
   3.428      Value _value;
   3.429 -    Map _map;
   3.430  
   3.431    public:
   3.432  
   3.433 -    /// Constructor with specified default value
   3.434 -    StdMap(const T& value = T()) : _value(value) {}
   3.435 -    /// \brief Constructs the map from an appropriate \c std::map, and 
   3.436 +    /// \brief Constructor with specified default value.
   3.437 +    SparseMap(const Value &value = Value()) : _value(value) {}
   3.438 +    /// \brief Constructs the map from an appropriate \c std::map, and
   3.439      /// explicitly specifies a default value.
   3.440 -    template <typename T1, typename Comp1>
   3.441 -    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
   3.442 +    template <typename V1, typename Comp1>
   3.443 +    SparseMap(const std::map<Key, V1, Comp1> &map,
   3.444 +              const Value &value = Value())
   3.445        : _map(map.begin(), map.end()), _value(value) {}
   3.446 -    
   3.447 -    /// \brief Constructs a map from an other \ref StdMap.
   3.448 -    template<typename T1, typename Comp1>
   3.449 -    StdMap(const StdMap<Key, T1, Comp1> &c) 
   3.450 +
   3.451 +    /// \brief Constructs the map from another \ref SparseMap.
   3.452 +    template<typename V1, typename Comp1>
   3.453 +    SparseMap(const SparseMap<Key, V1, Comp1> &c)
   3.454        : _map(c._map.begin(), c._map.end()), _value(c._value) {}
   3.455  
   3.456    private:
   3.457  
   3.458 -    StdMap& operator=(const StdMap&);
   3.459 +    SparseMap& operator=(const SparseMap&);
   3.460  
   3.461    public:
   3.462  
   3.463 @@ -219,7 +404,7 @@
   3.464  	return _map.insert(it, std::make_pair(k, _value))->second;
   3.465      }
   3.466  
   3.467 -    /// \e 
   3.468 +    ///\e
   3.469      ConstReference operator[](const Key &k) const {
   3.470        typename Map::const_iterator it = _map.find(k);
   3.471        if (it != _map.end())
   3.472 @@ -228,149 +413,48 @@
   3.473  	return _value;
   3.474      }
   3.475  
   3.476 -    /// \e 
   3.477 -    void set(const Key &k, const T &t) {
   3.478 +    ///\e
   3.479 +    void set(const Key &k, const Value &v) {
   3.480        typename Map::iterator it = _map.lower_bound(k);
   3.481        if (it != _map.end() && !_map.key_comp()(k, it->first))
   3.482 -	it->second = t;
   3.483 +	it->second = v;
   3.484        else
   3.485 -	_map.insert(it, std::make_pair(k, t));
   3.486 +	_map.insert(it, std::make_pair(k, v));
   3.487      }
   3.488  
   3.489 -    /// \e
   3.490 -    void setAll(const T &t) {
   3.491 -      _value = t;
   3.492 +    ///\e
   3.493 +    void setAll(const Value &v) {
   3.494 +      _value = v;
   3.495        _map.clear();
   3.496 -    }    
   3.497 +    }
   3.498 +  };
   3.499  
   3.500 -  };
   3.501 -  
   3.502 -  ///Returns a \c StdMap class
   3.503 +  /// Returns a \ref SparseMap class
   3.504  
   3.505 -  ///This function just returns a \c StdMap class with specified 
   3.506 -  ///default value.
   3.507 -  ///\relates StdMap
   3.508 -  template<typename K, typename V, typename Compare> 
   3.509 -  inline StdMap<K, V, Compare> stdMap(const V& value = V()) {
   3.510 -    return StdMap<K, V, Compare>(value);
   3.511 -  }
   3.512 -  
   3.513 -  ///Returns a \c StdMap class
   3.514 -
   3.515 -  ///This function just returns a \c StdMap class with specified 
   3.516 -  ///default value.
   3.517 -  ///\relates StdMap
   3.518 -  template<typename K, typename V> 
   3.519 -  inline StdMap<K, V, std::less<K> > stdMap(const V& value = V()) {
   3.520 -    return StdMap<K, V, std::less<K> >(value);
   3.521 -  }
   3.522 -  
   3.523 -  ///Returns a \c StdMap class created from an appropriate std::map
   3.524 -
   3.525 -  ///This function just returns a \c StdMap class created from an 
   3.526 -  ///appropriate std::map.
   3.527 -  ///\relates StdMap
   3.528 -  template<typename K, typename V, typename Compare> 
   3.529 -  inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, 
   3.530 -                                       const V& value = V() ) {
   3.531 -    return StdMap<K, V, Compare>(map, value);
   3.532 +  /// This function just returns a \ref SparseMap class with specified
   3.533 +  /// default value.
   3.534 +  /// \relates SparseMap
   3.535 +  template<typename K, typename V, typename Compare>
   3.536 +  inline SparseMap<K, V, Compare> sparseMap(const V& value = V()) {
   3.537 +    return SparseMap<K, V, Compare>(value);
   3.538    }
   3.539  
   3.540 -  ///Returns a \c StdMap class created from an appropriate std::map
   3.541 -
   3.542 -  ///This function just returns a \c StdMap class created from an 
   3.543 -  ///appropriate std::map.
   3.544 -  ///\relates StdMap
   3.545 -  template<typename K, typename V> 
   3.546 -  inline StdMap<K, V, std::less<K> > stdMap( const std::map<K, V, std::less<K> > &map, 
   3.547 -                                             const V& value = V() ) {
   3.548 -    return StdMap<K, V, std::less<K> >(map, value);
   3.549 +  template<typename K, typename V>
   3.550 +  inline SparseMap<K, V, std::less<K> > sparseMap(const V& value = V()) {
   3.551 +    return SparseMap<K, V, std::less<K> >(value);
   3.552    }
   3.553  
   3.554 -  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
   3.555 -  ///
   3.556 -  /// This map has the <tt>[0..size-1]</tt> keyset and the values
   3.557 -  /// are stored in a \c std::vector<T>  container. It can be used with
   3.558 -  /// some data structures, for example \c UnionFind, \c BinHeap, when 
   3.559 -  /// the used items are small integer numbers.
   3.560 -  /// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
   3.561 -  ///
   3.562 -  /// \todo Revise its name
   3.563 -  template <typename T>
   3.564 -  class IntegerMap : public MapBase<int, T> {
   3.565 +  /// \brief Returns a \ref SparseMap class created from an appropriate
   3.566 +  /// \c std::map
   3.567  
   3.568 -    template <typename T1>
   3.569 -    friend class IntegerMap;
   3.570 -
   3.571 -  public:
   3.572 -
   3.573 -    typedef MapBase<int, T> Parent;
   3.574 -    ///\e
   3.575 -    typedef typename Parent::Key Key;
   3.576 -    ///\e
   3.577 -    typedef typename Parent::Value Value;
   3.578 -    ///\e
   3.579 -    typedef T& Reference;
   3.580 -    ///\e
   3.581 -    typedef const T& ConstReference;
   3.582 -
   3.583 -    typedef True ReferenceMapTag;
   3.584 -
   3.585 -  private:
   3.586 -    
   3.587 -    typedef std::vector<T> Vector;
   3.588 -    Vector _vector;
   3.589 -
   3.590 -  public:
   3.591 -
   3.592 -    /// Constructor with specified default value
   3.593 -    IntegerMap(int size = 0, const T& value = T()) : _vector(size, value) {}
   3.594 -
   3.595 -    /// \brief Constructs the map from an appropriate \c std::vector.
   3.596 -    template <typename T1>
   3.597 -    IntegerMap(const std::vector<T1>& vector) 
   3.598 -      : _vector(vector.begin(), vector.end()) {}
   3.599 -    
   3.600 -    /// \brief Constructs a map from an other \ref IntegerMap.
   3.601 -    template <typename T1>
   3.602 -    IntegerMap(const IntegerMap<T1> &c) 
   3.603 -      : _vector(c._vector.begin(), c._vector.end()) {}
   3.604 -
   3.605 -    /// \brief Resize the container
   3.606 -    void resize(int size, const T& value = T()) {
   3.607 -      _vector.resize(size, value);
   3.608 -    }
   3.609 -
   3.610 -  private:
   3.611 -
   3.612 -    IntegerMap& operator=(const IntegerMap&);
   3.613 -
   3.614 -  public:
   3.615 -
   3.616 -    ///\e
   3.617 -    Reference operator[](Key k) {
   3.618 -      return _vector[k];
   3.619 -    }
   3.620 -
   3.621 -    /// \e 
   3.622 -    ConstReference operator[](Key k) const {
   3.623 -      return _vector[k];
   3.624 -    }
   3.625 -
   3.626 -    /// \e 
   3.627 -    void set(const Key &k, const T& t) {
   3.628 -      _vector[k] = t;
   3.629 -    }
   3.630 -
   3.631 -  };
   3.632 -  
   3.633 -  ///Returns an \c IntegerMap class
   3.634 -
   3.635 -  ///This function just returns an \c IntegerMap class.
   3.636 -  ///\relates IntegerMap
   3.637 -  template<typename T>
   3.638 -  inline IntegerMap<T> integerMap(int size = 0, const T& value = T()) {
   3.639 -    return IntegerMap<T>(size, value);
   3.640 +  /// This function just returns a \ref SparseMap class created from an
   3.641 +  /// appropriate \c std::map.
   3.642 +  /// \relates SparseMap
   3.643 +  template<typename K, typename V, typename Compare>
   3.644 +  inline SparseMap<K, V, Compare>
   3.645 +    sparseMap(const std::map<K, V, Compare> &map, const V& value = V())
   3.646 +  {
   3.647 +    return SparseMap<K, V, Compare>(map, value);
   3.648    }
   3.649  
   3.650    /// @}
   3.651 @@ -378,1260 +462,1210 @@
   3.652    /// \addtogroup map_adaptors
   3.653    /// @{
   3.654  
   3.655 -  /// \brief Identity map.
   3.656 +  /// Composition of two maps
   3.657 +
   3.658 +  /// This \ref concepts::ReadMap "read-only map" returns the
   3.659 +  /// composition of two given maps. That is to say, if \c m1 is of
   3.660 +  /// type \c M1 and \c m2 is of \c M2, then for
   3.661 +  /// \code
   3.662 +  ///   ComposeMap<M1, M2> cm(m1,m2);
   3.663 +  /// \endcode
   3.664 +  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
   3.665    ///
   3.666 -  /// This map gives back the given key as value without any
   3.667 -  /// modification. 
   3.668 -  template <typename T>
   3.669 -  class IdentityMap : public MapBase<T, T> {
   3.670 +  /// The \c Key type of the map is inherited from \c M2 and the
   3.671 +  /// \c Value type is from \c M1.
   3.672 +  /// \c M2::Value must be convertible to \c M1::Key.
   3.673 +  ///
   3.674 +  /// The simplest way of using this map is through the composeMap()
   3.675 +  /// function.
   3.676 +  ///
   3.677 +  /// \sa CombineMap
   3.678 +  ///
   3.679 +  /// \todo Check the requirements.
   3.680 +  template <typename M1, typename M2>
   3.681 +  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
   3.682 +    const M1 &_m1;
   3.683 +    const M2 &_m2;
   3.684    public:
   3.685 -    typedef MapBase<T, T> Parent;
   3.686 +    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
   3.687      typedef typename Parent::Key Key;
   3.688      typedef typename Parent::Value Value;
   3.689  
   3.690 +    /// Constructor
   3.691 +    ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
   3.692 +
   3.693      /// \e
   3.694 -    const T& operator[](const T& t) const {
   3.695 -      return t;
   3.696 -    }
   3.697 +    typename MapTraits<M1>::ConstReturnValue
   3.698 +    operator[](const Key &k) const { return _m1[_m2[k]]; }
   3.699    };
   3.700  
   3.701 -  ///Returns an \c IdentityMap class
   3.702 +  /// Returns a \ref ComposeMap class
   3.703  
   3.704 -  ///This function just returns an \c IdentityMap class.
   3.705 -  ///\relates IdentityMap
   3.706 -  template<typename T>
   3.707 -  inline IdentityMap<T> identityMap() {
   3.708 -    return IdentityMap<T>();
   3.709 +  /// This function just returns a \ref ComposeMap class.
   3.710 +  ///
   3.711 +  /// If \c m1 and \c m2 are maps and the \c Value type of \c m2 is
   3.712 +  /// convertible to the \c Key of \c m1, then <tt>composeMap(m1,m2)[x]</tt>
   3.713 +  /// will be equal to <tt>m1[m2[x]]</tt>.
   3.714 +  ///
   3.715 +  /// \relates ComposeMap
   3.716 +  template <typename M1, typename M2>
   3.717 +  inline ComposeMap<M1, M2> composeMap(const M1 &m1, const M2 &m2) {
   3.718 +    return ComposeMap<M1, M2>(m1, m2);
   3.719    }
   3.720 -  
   3.721  
   3.722 -  ///\brief Convert the \c Value of a map to another type using
   3.723 -  ///the default conversion.
   3.724 +
   3.725 +  /// Combination of two maps using an STL (binary) functor.
   3.726 +
   3.727 +  /// This \ref concepts::ReadMap "read-only map" takes two maps and a
   3.728 +  /// binary functor and returns the combination of the two given maps
   3.729 +  /// using the functor.
   3.730 +  /// That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2
   3.731 +  /// and \c f is of \c F, then for
   3.732 +  /// \code
   3.733 +  ///   CombineMap<M1,M2,F,V> cm(m1,m2,f);
   3.734 +  /// \endcode
   3.735 +  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>.
   3.736    ///
   3.737 -  ///This \ref concepts::ReadMap "read only map"
   3.738 -  ///converts the \c Value of a map to type \c T.
   3.739 -  ///Its \c Key is inherited from \c M.
   3.740 -  template <typename M, typename T> 
   3.741 -  class ConvertMap : public MapBase<typename M::Key, T> {
   3.742 -    const M& m;
   3.743 +  /// The \c Key type of the map is inherited from \c M1 (\c M1::Key
   3.744 +  /// must be convertible to \c M2::Key) and the \c Value type is \c V.
   3.745 +  /// \c M2::Value and \c M1::Value must be convertible to the
   3.746 +  /// corresponding input parameter of \c F and the return type of \c F
   3.747 +  /// must be convertible to \c V.
   3.748 +  ///
   3.749 +  /// The simplest way of using this map is through the combineMap()
   3.750 +  /// function.
   3.751 +  ///
   3.752 +  /// \sa ComposeMap
   3.753 +  ///
   3.754 +  /// \todo Check the requirements.
   3.755 +  template<typename M1, typename M2, typename F,
   3.756 +	   typename V = typename F::result_type>
   3.757 +  class CombineMap : public MapBase<typename M1::Key, V> {
   3.758 +    const M1 &_m1;
   3.759 +    const M2 &_m2;
   3.760 +    F _f;
   3.761    public:
   3.762 -    typedef MapBase<typename M::Key, T> Parent;
   3.763 +    typedef MapBase<typename M1::Key, V> Parent;
   3.764      typedef typename Parent::Key Key;
   3.765      typedef typename Parent::Value Value;
   3.766  
   3.767 -    ///Constructor
   3.768 +    /// Constructor
   3.769 +    CombineMap(const M1 &m1, const M2 &m2, const F &f = F())
   3.770 +      : _m1(m1), _m2(m2), _f(f) {}
   3.771 +    /// \e
   3.772 +    Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); }
   3.773 +  };
   3.774  
   3.775 -    ///Constructor.
   3.776 -    ///\param _m is the underlying map.
   3.777 -    ConvertMap(const M &_m) : m(_m) {};
   3.778 +  /// Returns a \ref CombineMap class
   3.779  
   3.780 -    ///\e
   3.781 -    Value operator[](const Key& k) const {return m[k];}
   3.782 -  };
   3.783 -  
   3.784 -  ///Returns a \c ConvertMap class
   3.785 -
   3.786 -  ///This function just returns a \c ConvertMap class.
   3.787 -  ///\relates ConvertMap
   3.788 -  template<typename T, typename M>
   3.789 -  inline ConvertMap<M, T> convertMap(const M &m) {
   3.790 -    return ConvertMap<M, T>(m);
   3.791 +  /// This function just returns a \ref CombineMap class.
   3.792 +  ///
   3.793 +  /// For example, if \c m1 and \c m2 are both maps with \c double
   3.794 +  /// values, then
   3.795 +  /// \code
   3.796 +  ///   combineMap(m1,m2,std::plus<double>())
   3.797 +  /// \endcode
   3.798 +  /// is equivalent to
   3.799 +  /// \code
   3.800 +  ///   addMap(m1,m2)
   3.801 +  /// \endcode
   3.802 +  ///
   3.803 +  /// This function is specialized for adaptable binary function
   3.804 +  /// classes and C++ functions.
   3.805 +  ///
   3.806 +  /// \relates CombineMap
   3.807 +  template<typename M1, typename M2, typename F, typename V>
   3.808 +  inline CombineMap<M1, M2, F, V>
   3.809 +  combineMap(const M1 &m1, const M2 &m2, const F &f) {
   3.810 +    return CombineMap<M1, M2, F, V>(m1,m2,f);
   3.811    }
   3.812  
   3.813 -  ///Simple wrapping of a map
   3.814 +  template<typename M1, typename M2, typename F>
   3.815 +  inline CombineMap<M1, M2, F, typename F::result_type>
   3.816 +  combineMap(const M1 &m1, const M2 &m2, const F &f) {
   3.817 +    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
   3.818 +  }
   3.819  
   3.820 -  ///This \ref concepts::ReadMap "read only map" returns the simple
   3.821 -  ///wrapping of the given map. Sometimes the reference maps cannot be
   3.822 -  ///combined with simple read maps. This map adaptor wraps the given
   3.823 -  ///map to simple read map.
   3.824 +  template<typename M1, typename M2, typename K1, typename K2, typename V>
   3.825 +  inline CombineMap<M1, M2, V (*)(K1, K2), V>
   3.826 +  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
   3.827 +    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
   3.828 +  }
   3.829 +
   3.830 +
   3.831 +  /// Converts an STL style (unary) functor to a map
   3.832 +
   3.833 +  /// This \ref concepts::ReadMap "read-only map" returns the value
   3.834 +  /// of a given functor. Actually, it just wraps the functor and
   3.835 +  /// provides the \c Key and \c Value typedefs.
   3.836    ///
   3.837 -  ///\sa SimpleWriteMap
   3.838 +  /// Template parameters \c K and \c V will become its \c Key and
   3.839 +  /// \c Value. In most cases they have to be given explicitly because
   3.840 +  /// a functor typically does not provide \c argument_type and
   3.841 +  /// \c result_type typedefs.
   3.842 +  /// Parameter \c F is the type of the used functor.
   3.843    ///
   3.844 -  /// \todo Revise the misleading name 
   3.845 -  template<typename M> 
   3.846 -  class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
   3.847 -    const M& m;
   3.848 +  /// The simplest way of using this map is through the functorToMap()
   3.849 +  /// function.
   3.850 +  ///
   3.851 +  /// \sa MapToFunctor
   3.852 +  template<typename F,
   3.853 +	   typename K = typename F::argument_type,
   3.854 +	   typename V = typename F::result_type>
   3.855 +  class FunctorToMap : public MapBase<K, V> {
   3.856 +    const F &_f;
   3.857 +  public:
   3.858 +    typedef MapBase<K, V> Parent;
   3.859 +    typedef typename Parent::Key Key;
   3.860 +    typedef typename Parent::Value Value;
   3.861  
   3.862 +    /// Constructor
   3.863 +    FunctorToMap(const F &f = F()) : _f(f) {}
   3.864 +    /// \e
   3.865 +    Value operator[](const Key &k) const { return _f(k); }
   3.866 +  };
   3.867 +
   3.868 +  /// Returns a \ref FunctorToMap class
   3.869 +
   3.870 +  /// This function just returns a \ref FunctorToMap class.
   3.871 +  ///
   3.872 +  /// This function is specialized for adaptable binary function
   3.873 +  /// classes and C++ functions.
   3.874 +  ///
   3.875 +  /// \relates FunctorToMap
   3.876 +  template<typename K, typename V, typename F>
   3.877 +  inline FunctorToMap<F, K, V> functorToMap(const F &f) {
   3.878 +    return FunctorToMap<F, K, V>(f);
   3.879 +  }
   3.880 +
   3.881 +  template <typename F>
   3.882 +  inline FunctorToMap<F, typename F::argument_type, typename F::result_type>
   3.883 +    functorToMap(const F &f)
   3.884 +  {
   3.885 +    return FunctorToMap<F, typename F::argument_type,
   3.886 +      typename F::result_type>(f);
   3.887 +  }
   3.888 +
   3.889 +  template <typename K, typename V>
   3.890 +  inline FunctorToMap<V (*)(K), K, V> functorToMap(V (*f)(K)) {
   3.891 +    return FunctorToMap<V (*)(K), K, V>(f);
   3.892 +  }
   3.893 +
   3.894 +
   3.895 +  /// Converts a map to an STL style (unary) functor
   3.896 +
   3.897 +  /// This class converts a map to an STL style (unary) functor.
   3.898 +  /// That is it provides an <tt>operator()</tt> to read its values.
   3.899 +  ///
   3.900 +  /// For the sake of convenience it also works as a usual
   3.901 +  /// \ref concepts::ReadMap "readable map", i.e. <tt>operator[]</tt>
   3.902 +  /// and the \c Key and \c Value typedefs also exist.
   3.903 +  ///
   3.904 +  /// The simplest way of using this map is through the mapToFunctor()
   3.905 +  /// function.
   3.906 +  ///
   3.907 +  ///\sa FunctorToMap
   3.908 +  template <typename M>
   3.909 +  class MapToFunctor : public MapBase<typename M::Key, typename M::Value> {
   3.910 +    const M &_m;
   3.911    public:
   3.912      typedef MapBase<typename M::Key, typename M::Value> Parent;
   3.913      typedef typename Parent::Key Key;
   3.914      typedef typename Parent::Value Value;
   3.915  
   3.916 -    ///Constructor
   3.917 -    SimpleMap(const M &_m) : m(_m) {};
   3.918 -    ///\e
   3.919 -    Value operator[](Key k) const {return m[k];}
   3.920 +    typedef typename Parent::Key argument_type;
   3.921 +    typedef typename Parent::Value result_type;
   3.922 +
   3.923 +    /// Constructor
   3.924 +    MapToFunctor(const M &m) : _m(m) {}
   3.925 +    /// \e
   3.926 +    Value operator()(const Key &k) const { return _m[k]; }
   3.927 +    /// \e
   3.928 +    Value operator[](const Key &k) const { return _m[k]; }
   3.929    };
   3.930 -  
   3.931 -  ///Returns a \c SimpleMap class
   3.932  
   3.933 -  ///This function just returns a \c SimpleMap class.
   3.934 -  ///\relates SimpleMap
   3.935 +  /// Returns a \ref MapToFunctor class
   3.936 +
   3.937 +  /// This function just returns a \ref MapToFunctor class.
   3.938 +  /// \relates MapToFunctor
   3.939    template<typename M>
   3.940 -  inline SimpleMap<M> simpleMap(const M &m) {
   3.941 -    return SimpleMap<M>(m);
   3.942 +  inline MapToFunctor<M> mapToFunctor(const M &m) {
   3.943 +    return MapToFunctor<M>(m);
   3.944    }
   3.945  
   3.946 -  ///Simple writable wrapping of a map
   3.947  
   3.948 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the simple
   3.949 -  ///wrapping of the given map. Sometimes the reference maps cannot be
   3.950 -  ///combined with simple read-write maps. This map adaptor wraps the
   3.951 -  ///given map to simple read-write map.
   3.952 +  /// \brief Map adaptor to convert the \c Value type of a map to
   3.953 +  /// another type using the default conversion.
   3.954 +
   3.955 +  /// Map adaptor to convert the \c Value type of a \ref concepts::ReadMap
   3.956 +  /// "readable map" to another type using the default conversion.
   3.957 +  /// The \c Key type of it is inherited from \c M and the \c Value
   3.958 +  /// type is \c V.
   3.959 +  /// This type conforms the \ref concepts::ReadMap "ReadMap" concept.
   3.960    ///
   3.961 -  ///\sa SimpleMap
   3.962 +  /// The simplest way of using this map is through the convertMap()
   3.963 +  /// function.
   3.964 +  template <typename M, typename V>
   3.965 +  class ConvertMap : public MapBase<typename M::Key, V> {
   3.966 +    const M &_m;
   3.967 +  public:
   3.968 +    typedef MapBase<typename M::Key, V> Parent;
   3.969 +    typedef typename Parent::Key Key;
   3.970 +    typedef typename Parent::Value Value;
   3.971 +
   3.972 +    /// Constructor
   3.973 +
   3.974 +    /// Constructor.
   3.975 +    /// \param m The underlying map.
   3.976 +    ConvertMap(const M &m) : _m(m) {}
   3.977 +
   3.978 +    /// \e
   3.979 +    Value operator[](const Key &k) const { return _m[k]; }
   3.980 +  };
   3.981 +
   3.982 +  /// Returns a \ref ConvertMap class
   3.983 +
   3.984 +  /// This function just returns a \ref ConvertMap class.
   3.985 +  /// \relates ConvertMap
   3.986 +  template<typename V, typename M>
   3.987 +  inline ConvertMap<M, V> convertMap(const M &map) {
   3.988 +    return ConvertMap<M, V>(map);
   3.989 +  }
   3.990 +
   3.991 +
   3.992 +  /// Applies all map setting operations to two maps
   3.993 +
   3.994 +  /// This map has two \ref concepts::WriteMap "writable map" parameters
   3.995 +  /// and each write request will be passed to both of them.
   3.996 +  /// If \c M1 is also \ref concepts::ReadMap "readable", then the read
   3.997 +  /// operations will return the corresponding values of \c M1.
   3.998    ///
   3.999 -  /// \todo Revise the misleading name
  3.1000 -  template<typename M> 
  3.1001 -  class SimpleWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1002 -    M& m;
  3.1003 +  /// The \c Key and \c Value types are inherited from \c M1.
  3.1004 +  /// The \c Key and \c Value of \c M2 must be convertible from those
  3.1005 +  /// of \c M1.
  3.1006 +  ///
  3.1007 +  /// The simplest way of using this map is through the forkMap()
  3.1008 +  /// function.
  3.1009 +  template<typename  M1, typename M2>
  3.1010 +  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1011 +    M1 &_m1;
  3.1012 +    M2 &_m2;
  3.1013 +  public:
  3.1014 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1015 +    typedef typename Parent::Key Key;
  3.1016 +    typedef typename Parent::Value Value;
  3.1017  
  3.1018 +    /// Constructor
  3.1019 +    ForkMap(M1 &m1, M2 &m2) : _m1(m1), _m2(m2) {}
  3.1020 +    /// Returns the value associated with the given key in the first map.
  3.1021 +    Value operator[](const Key &k) const { return _m1[k]; }
  3.1022 +    /// Sets the value associated with the given key in both maps.
  3.1023 +    void set(const Key &k, const Value &v) { _m1.set(k,v); _m2.set(k,v); }
  3.1024 +  };
  3.1025 +
  3.1026 +  /// Returns a \ref ForkMap class
  3.1027 +
  3.1028 +  /// This function just returns a \ref ForkMap class.
  3.1029 +  /// \relates ForkMap
  3.1030 +  template <typename M1, typename M2>
  3.1031 +  inline ForkMap<M1,M2> forkMap(M1 &m1, M2 &m2) {
  3.1032 +    return ForkMap<M1,M2>(m1,m2);
  3.1033 +  }
  3.1034 +
  3.1035 +
  3.1036 +  /// Sum of two maps
  3.1037 +
  3.1038 +  /// This \ref concepts::ReadMap "read-only map" returns the sum
  3.1039 +  /// of the values of the two given maps.
  3.1040 +  /// Its \c Key and \c Value types are inherited from \c M1.
  3.1041 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  3.1042 +  /// \c M1.
  3.1043 +  ///
  3.1044 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.1045 +  /// \code
  3.1046 +  ///   AddMap<M1,M2> am(m1,m2);
  3.1047 +  /// \endcode
  3.1048 +  /// <tt>am[x]</tt> will be equal to <tt>m1[x]+m2[x]</tt>.
  3.1049 +  ///
  3.1050 +  /// The simplest way of using this map is through the addMap()
  3.1051 +  /// function.
  3.1052 +  ///
  3.1053 +  /// \sa SubMap, MulMap, DivMap
  3.1054 +  /// \sa ShiftMap, ShiftWriteMap
  3.1055 +  template<typename M1, typename M2>
  3.1056 +  class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1057 +    const M1 &_m1;
  3.1058 +    const M2 &_m2;
  3.1059 +  public:
  3.1060 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1061 +    typedef typename Parent::Key Key;
  3.1062 +    typedef typename Parent::Value Value;
  3.1063 +
  3.1064 +    /// Constructor
  3.1065 +    AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  3.1066 +    /// \e
  3.1067 +    Value operator[](const Key &k) const { return _m1[k]+_m2[k]; }
  3.1068 +  };
  3.1069 +
  3.1070 +  /// Returns an \ref AddMap class
  3.1071 +
  3.1072 +  /// This function just returns an \ref AddMap class.
  3.1073 +  ///
  3.1074 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  3.1075 +  /// values, then <tt>addMap(m1,m2)[x]</tt> will be equal to
  3.1076 +  /// <tt>m1[x]+m2[x]</tt>.
  3.1077 +  ///
  3.1078 +  /// \relates AddMap
  3.1079 +  template<typename M1, typename M2>
  3.1080 +  inline AddMap<M1, M2> addMap(const M1 &m1, const M2 &m2) {
  3.1081 +    return AddMap<M1, M2>(m1,m2);
  3.1082 +  }
  3.1083 +
  3.1084 +
  3.1085 +  /// Difference of two maps
  3.1086 +
  3.1087 +  /// This \ref concepts::ReadMap "read-only map" returns the difference
  3.1088 +  /// of the values of the two given maps.
  3.1089 +  /// Its \c Key and \c Value types are inherited from \c M1.
  3.1090 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  3.1091 +  /// \c M1.
  3.1092 +  ///
  3.1093 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.1094 +  /// \code
  3.1095 +  ///   SubMap<M1,M2> sm(m1,m2);
  3.1096 +  /// \endcode
  3.1097 +  /// <tt>sm[x]</tt> will be equal to <tt>m1[x]-m2[x]</tt>.
  3.1098 +  ///
  3.1099 +  /// The simplest way of using this map is through the subMap()
  3.1100 +  /// function.
  3.1101 +  ///
  3.1102 +  /// \sa AddMap, MulMap, DivMap
  3.1103 +  template<typename M1, typename M2>
  3.1104 +  class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1105 +    const M1 &_m1;
  3.1106 +    const M2 &_m2;
  3.1107 +  public:
  3.1108 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1109 +    typedef typename Parent::Key Key;
  3.1110 +    typedef typename Parent::Value Value;
  3.1111 +
  3.1112 +    /// Constructor
  3.1113 +    SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  3.1114 +    /// \e
  3.1115 +    Value operator[](const Key &k) const { return _m1[k]-_m2[k]; }
  3.1116 +  };
  3.1117 +
  3.1118 +  /// Returns a \ref SubMap class
  3.1119 +
  3.1120 +  /// This function just returns a \ref SubMap class.
  3.1121 +  ///
  3.1122 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  3.1123 +  /// values, then <tt>subMap(m1,m2)[x]</tt> will be equal to
  3.1124 +  /// <tt>m1[x]-m2[x]</tt>.
  3.1125 +  ///
  3.1126 +  /// \relates SubMap
  3.1127 +  template<typename M1, typename M2>
  3.1128 +  inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
  3.1129 +    return SubMap<M1, M2>(m1,m2);
  3.1130 +  }
  3.1131 +
  3.1132 +
  3.1133 +  /// Product of two maps
  3.1134 +
  3.1135 +  /// This \ref concepts::ReadMap "read-only map" returns the product
  3.1136 +  /// of the values of the two given maps.
  3.1137 +  /// Its \c Key and \c Value types are inherited from \c M1.
  3.1138 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  3.1139 +  /// \c M1.
  3.1140 +  ///
  3.1141 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.1142 +  /// \code
  3.1143 +  ///   MulMap<M1,M2> mm(m1,m2);
  3.1144 +  /// \endcode
  3.1145 +  /// <tt>mm[x]</tt> will be equal to <tt>m1[x]*m2[x]</tt>.
  3.1146 +  ///
  3.1147 +  /// The simplest way of using this map is through the mulMap()
  3.1148 +  /// function.
  3.1149 +  ///
  3.1150 +  /// \sa AddMap, SubMap, DivMap
  3.1151 +  /// \sa ScaleMap, ScaleWriteMap
  3.1152 +  template<typename M1, typename M2>
  3.1153 +  class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1154 +    const M1 &_m1;
  3.1155 +    const M2 &_m2;
  3.1156 +  public:
  3.1157 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1158 +    typedef typename Parent::Key Key;
  3.1159 +    typedef typename Parent::Value Value;
  3.1160 +
  3.1161 +    /// Constructor
  3.1162 +    MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
  3.1163 +    /// \e
  3.1164 +    Value operator[](const Key &k) const { return _m1[k]*_m2[k]; }
  3.1165 +  };
  3.1166 +
  3.1167 +  /// Returns a \ref MulMap class
  3.1168 +
  3.1169 +  /// This function just returns a \ref MulMap class.
  3.1170 +  ///
  3.1171 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  3.1172 +  /// values, then <tt>mulMap(m1,m2)[x]</tt> will be equal to
  3.1173 +  /// <tt>m1[x]*m2[x]</tt>.
  3.1174 +  ///
  3.1175 +  /// \relates MulMap
  3.1176 +  template<typename M1, typename M2>
  3.1177 +  inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
  3.1178 +    return MulMap<M1, M2>(m1,m2);
  3.1179 +  }
  3.1180 +
  3.1181 +
  3.1182 +  /// Quotient of two maps
  3.1183 +
  3.1184 +  /// This \ref concepts::ReadMap "read-only map" returns the quotient
  3.1185 +  /// of the values of the two given maps.
  3.1186 +  /// Its \c Key and \c Value types are inherited from \c M1.
  3.1187 +  /// The \c Key and \c Value of \c M2 must be convertible to those of
  3.1188 +  /// \c M1.
  3.1189 +  ///
  3.1190 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.1191 +  /// \code
  3.1192 +  ///   DivMap<M1,M2> dm(m1,m2);
  3.1193 +  /// \endcode
  3.1194 +  /// <tt>dm[x]</tt> will be equal to <tt>m1[x]/m2[x]</tt>.
  3.1195 +  ///
  3.1196 +  /// The simplest way of using this map is through the divMap()
  3.1197 +  /// function.
  3.1198 +  ///
  3.1199 +  /// \sa AddMap, SubMap, MulMap
  3.1200 +  template<typename M1, typename M2>
  3.1201 +  class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1202 +    const M1 &_m1;
  3.1203 +    const M2 &_m2;
  3.1204 +  public:
  3.1205 +    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1206 +    typedef typename Parent::Key Key;
  3.1207 +    typedef typename Parent::Value Value;
  3.1208 +
  3.1209 +    /// Constructor
  3.1210 +    DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
  3.1211 +    /// \e
  3.1212 +    Value operator[](const Key &k) const { return _m1[k]/_m2[k]; }
  3.1213 +  };
  3.1214 +
  3.1215 +  /// Returns a \ref DivMap class
  3.1216 +
  3.1217 +  /// This function just returns a \ref DivMap class.
  3.1218 +  ///
  3.1219 +  /// For example, if \c m1 and \c m2 are both maps with \c double
  3.1220 +  /// values, then <tt>divMap(m1,m2)[x]</tt> will be equal to
  3.1221 +  /// <tt>m1[x]/m2[x]</tt>.
  3.1222 +  ///
  3.1223 +  /// \relates DivMap
  3.1224 +  template<typename M1, typename M2>
  3.1225 +  inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
  3.1226 +    return DivMap<M1, M2>(m1,m2);
  3.1227 +  }
  3.1228 +
  3.1229 +
  3.1230 +  /// Shifts a map with a constant.
  3.1231 +
  3.1232 +  /// This \ref concepts::ReadMap "read-only map" returns the sum of
  3.1233 +  /// the given map and a constant value (i.e. it shifts the map with
  3.1234 +  /// the constant). Its \c Key and \c Value are inherited from \c M.
  3.1235 +  ///
  3.1236 +  /// Actually,
  3.1237 +  /// \code
  3.1238 +  ///   ShiftMap<M> sh(m,v);
  3.1239 +  /// \endcode
  3.1240 +  /// is equivalent to
  3.1241 +  /// \code
  3.1242 +  ///   ConstMap<M::Key, M::Value> cm(v);
  3.1243 +  ///   AddMap<M, ConstMap<M::Key, M::Value> > sh(m,cm);
  3.1244 +  /// \endcode
  3.1245 +  ///
  3.1246 +  /// The simplest way of using this map is through the shiftMap()
  3.1247 +  /// function.
  3.1248 +  ///
  3.1249 +  /// \sa ShiftWriteMap
  3.1250 +  template<typename M, typename C = typename M::Value>
  3.1251 +  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
  3.1252 +    const M &_m;
  3.1253 +    C _v;
  3.1254    public:
  3.1255      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1256      typedef typename Parent::Key Key;
  3.1257      typedef typename Parent::Value Value;
  3.1258  
  3.1259 -    ///Constructor
  3.1260 -    SimpleWriteMap(M &_m) : m(_m) {};
  3.1261 -    ///\e
  3.1262 -    Value operator[](Key k) const {return m[k];}
  3.1263 -    ///\e
  3.1264 -    void set(Key k, const Value& c) { m.set(k, c); }
  3.1265 +    /// Constructor
  3.1266 +
  3.1267 +    /// Constructor.
  3.1268 +    /// \param m The undelying map.
  3.1269 +    /// \param v The constant value.
  3.1270 +    ShiftMap(const M &m, const C &v) : _m(m), _v(v) {}
  3.1271 +    /// \e
  3.1272 +    Value operator[](const Key &k) const { return _m[k]+_v; }
  3.1273    };
  3.1274  
  3.1275 -  ///Returns a \c SimpleWriteMap class
  3.1276 +  /// Shifts a map with a constant (read-write version).
  3.1277  
  3.1278 -  ///This function just returns a \c SimpleWriteMap class.
  3.1279 -  ///\relates SimpleWriteMap
  3.1280 -  template<typename M>
  3.1281 -  inline SimpleWriteMap<M> simpleWriteMap(M &m) {
  3.1282 -    return SimpleWriteMap<M>(m);
  3.1283 -  }
  3.1284 -
  3.1285 -  ///Sum of two maps
  3.1286 -
  3.1287 -  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
  3.1288 -  ///given maps.
  3.1289 -  ///Its \c Key and \c Value are inherited from \c M1.
  3.1290 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  3.1291 -  template<typename M1, typename M2> 
  3.1292 -  class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1293 -    const M1& m1;
  3.1294 -    const M2& m2;
  3.1295 -
  3.1296 -  public:
  3.1297 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1298 -    typedef typename Parent::Key Key;
  3.1299 -    typedef typename Parent::Value Value;
  3.1300 -
  3.1301 -    ///Constructor
  3.1302 -    AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  3.1303 -    ///\e
  3.1304 -    Value operator[](Key k) const {return m1[k]+m2[k];}
  3.1305 -  };
  3.1306 -  
  3.1307 -  ///Returns an \c AddMap class
  3.1308 -
  3.1309 -  ///This function just returns an \c AddMap class.
  3.1310 -  ///\todo Extend the documentation: how to call these type of functions?
  3.1311 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the sum
  3.1312 +  /// of the given map and a constant value (i.e. it shifts the map with
  3.1313 +  /// the constant). Its \c Key and \c Value are inherited from \c M.
  3.1314 +  /// It makes also possible to write the map.
  3.1315    ///
  3.1316 -  ///\relates AddMap
  3.1317 -  template<typename M1, typename M2> 
  3.1318 -  inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
  3.1319 -    return AddMap<M1, M2>(m1,m2);
  3.1320 -  }
  3.1321 -
  3.1322 -  ///Shift a map with a constant.
  3.1323 -
  3.1324 -  ///This \ref concepts::ReadMap "read only map" returns the sum of the
  3.1325 -  ///given map and a constant value.
  3.1326 -  ///Its \c Key and \c Value are inherited from \c M.
  3.1327 +  /// The simplest way of using this map is through the shiftWriteMap()
  3.1328 +  /// function.
  3.1329    ///
  3.1330 -  ///Actually,
  3.1331 -  ///\code
  3.1332 -  ///  ShiftMap<X> sh(x,v);
  3.1333 -  ///\endcode
  3.1334 -  ///is equivalent to
  3.1335 -  ///\code
  3.1336 -  ///  ConstMap<X::Key, X::Value> c_tmp(v);
  3.1337 -  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
  3.1338 -  ///\endcode
  3.1339 -  ///
  3.1340 -  ///\sa ShiftWriteMap
  3.1341 -  template<typename M, typename C = typename M::Value> 
  3.1342 -  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
  3.1343 -    const M& m;
  3.1344 -    C v;
  3.1345 +  /// \sa ShiftMap
  3.1346 +  template<typename M, typename C = typename M::Value>
  3.1347 +  class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1348 +    M &_m;
  3.1349 +    C _v;
  3.1350    public:
  3.1351      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1352      typedef typename Parent::Key Key;
  3.1353      typedef typename Parent::Value Value;
  3.1354  
  3.1355 -    ///Constructor
  3.1356 +    /// Constructor
  3.1357  
  3.1358 -    ///Constructor.
  3.1359 -    ///\param _m is the undelying map.
  3.1360 -    ///\param _v is the shift value.
  3.1361 -    ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
  3.1362 -    ///\e
  3.1363 -    Value operator[](Key k) const {return m[k] + v;}
  3.1364 +    /// Constructor.
  3.1365 +    /// \param m The undelying map.
  3.1366 +    /// \param v The constant value.
  3.1367 +    ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {}
  3.1368 +    /// \e
  3.1369 +    Value operator[](const Key &k) const { return _m[k]+_v; }
  3.1370 +    /// \e
  3.1371 +    void set(const Key &k, const Value &v) { _m.set(k, v-_v); }
  3.1372    };
  3.1373  
  3.1374 -  ///Shift a map with a constant (ReadWrite version).
  3.1375 +  /// Returns a \ref ShiftMap class
  3.1376  
  3.1377 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
  3.1378 -  ///given map and a constant value. It makes also possible to write the map.
  3.1379 -  ///Its \c Key and \c Value are inherited from \c M.
  3.1380 +  /// This function just returns a \ref ShiftMap class.
  3.1381    ///
  3.1382 -  ///\sa ShiftMap
  3.1383 -  template<typename M, typename C = typename M::Value> 
  3.1384 -  class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1385 -    M& m;
  3.1386 -    C v;
  3.1387 +  /// For example, if \c m is a map with \c double values and \c v is
  3.1388 +  /// \c double, then <tt>shiftMap(m,v)[x]</tt> will be equal to
  3.1389 +  /// <tt>m[x]+v</tt>.
  3.1390 +  ///
  3.1391 +  /// \relates ShiftMap
  3.1392 +  template<typename M, typename C>
  3.1393 +  inline ShiftMap<M, C> shiftMap(const M &m, const C &v) {
  3.1394 +    return ShiftMap<M, C>(m,v);
  3.1395 +  }
  3.1396 +
  3.1397 +  /// Returns a \ref ShiftWriteMap class
  3.1398 +
  3.1399 +  /// This function just returns a \ref ShiftWriteMap class.
  3.1400 +  ///
  3.1401 +  /// For example, if \c m is a map with \c double values and \c v is
  3.1402 +  /// \c double, then <tt>shiftWriteMap(m,v)[x]</tt> will be equal to
  3.1403 +  /// <tt>m[x]+v</tt>.
  3.1404 +  /// Moreover it makes also possible to write the map.
  3.1405 +  ///
  3.1406 +  /// \relates ShiftWriteMap
  3.1407 +  template<typename M, typename C>
  3.1408 +  inline ShiftWriteMap<M, C> shiftWriteMap(M &m, const C &v) {
  3.1409 +    return ShiftWriteMap<M, C>(m,v);
  3.1410 +  }
  3.1411 +
  3.1412 +
  3.1413 +  /// Scales a map with a constant.
  3.1414 +
  3.1415 +  /// This \ref concepts::ReadMap "read-only map" returns the value of
  3.1416 +  /// the given map multiplied from the left side with a constant value.
  3.1417 +  /// Its \c Key and \c Value are inherited from \c M.
  3.1418 +  ///
  3.1419 +  /// Actually,
  3.1420 +  /// \code
  3.1421 +  ///   ScaleMap<M> sc(m,v);
  3.1422 +  /// \endcode
  3.1423 +  /// is equivalent to
  3.1424 +  /// \code
  3.1425 +  ///   ConstMap<M::Key, M::Value> cm(v);
  3.1426 +  ///   MulMap<ConstMap<M::Key, M::Value>, M> sc(cm,m);
  3.1427 +  /// \endcode
  3.1428 +  ///
  3.1429 +  /// The simplest way of using this map is through the scaleMap()
  3.1430 +  /// function.
  3.1431 +  ///
  3.1432 +  /// \sa ScaleWriteMap
  3.1433 +  template<typename M, typename C = typename M::Value>
  3.1434 +  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
  3.1435 +    const M &_m;
  3.1436 +    C _v;
  3.1437    public:
  3.1438      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1439      typedef typename Parent::Key Key;
  3.1440      typedef typename Parent::Value Value;
  3.1441  
  3.1442 -    ///Constructor
  3.1443 +    /// Constructor
  3.1444  
  3.1445 -    ///Constructor.
  3.1446 -    ///\param _m is the undelying map.
  3.1447 -    ///\param _v is the shift value.
  3.1448 -    ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
  3.1449 +    /// Constructor.
  3.1450 +    /// \param m The undelying map.
  3.1451 +    /// \param v The constant value.
  3.1452 +    ScaleMap(const M &m, const C &v) : _m(m), _v(v) {}
  3.1453      /// \e
  3.1454 -    Value operator[](Key k) const {return m[k] + v;}
  3.1455 -    /// \e
  3.1456 -    void set(Key k, const Value& c) { m.set(k, c - v); }
  3.1457 +    Value operator[](const Key &k) const { return _v*_m[k]; }
  3.1458    };
  3.1459 -  
  3.1460 -  ///Returns a \c ShiftMap class
  3.1461  
  3.1462 -  ///This function just returns a \c ShiftMap class.
  3.1463 -  ///\relates ShiftMap
  3.1464 -  template<typename M, typename C> 
  3.1465 -  inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
  3.1466 -    return ShiftMap<M, C>(m,v);
  3.1467 -  }
  3.1468 +  /// Scales a map with a constant (read-write version).
  3.1469  
  3.1470 -  ///Returns a \c ShiftWriteMap class
  3.1471 -
  3.1472 -  ///This function just returns a \c ShiftWriteMap class.
  3.1473 -  ///\relates ShiftWriteMap
  3.1474 -  template<typename M, typename C> 
  3.1475 -  inline ShiftWriteMap<M, C> shiftMap(M &m,const C &v) {
  3.1476 -    return ShiftWriteMap<M, C>(m,v);
  3.1477 -  }
  3.1478 -
  3.1479 -  ///Difference of two maps
  3.1480 -
  3.1481 -  ///This \ref concepts::ReadMap "read only map" returns the difference
  3.1482 -  ///of the values of the two given maps.
  3.1483 -  ///Its \c Key and \c Value are inherited from \c M1.
  3.1484 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  3.1485 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the value of
  3.1486 +  /// the given map multiplied from the left side with a constant value.
  3.1487 +  /// Its \c Key and \c Value are inherited from \c M.
  3.1488 +  /// It can also be used as write map if the \c / operator is defined
  3.1489 +  /// between \c Value and \c C and the given multiplier is not zero.
  3.1490    ///
  3.1491 -  /// \todo Revise the misleading name
  3.1492 -  template<typename M1, typename M2> 
  3.1493 -  class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1494 -    const M1& m1;
  3.1495 -    const M2& m2;
  3.1496 -  public:
  3.1497 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1498 -    typedef typename Parent::Key Key;
  3.1499 -    typedef typename Parent::Value Value;
  3.1500 -
  3.1501 -    ///Constructor
  3.1502 -    SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  3.1503 -    /// \e
  3.1504 -    Value operator[](Key k) const {return m1[k]-m2[k];}
  3.1505 -  };
  3.1506 -  
  3.1507 -  ///Returns a \c SubMap class
  3.1508 -
  3.1509 -  ///This function just returns a \c SubMap class.
  3.1510 +  /// The simplest way of using this map is through the scaleWriteMap()
  3.1511 +  /// function.
  3.1512    ///
  3.1513 -  ///\relates SubMap
  3.1514 -  template<typename M1, typename M2> 
  3.1515 -  inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
  3.1516 -    return SubMap<M1, M2>(m1, m2);
  3.1517 -  }
  3.1518 -
  3.1519 -  ///Product of two maps
  3.1520 -
  3.1521 -  ///This \ref concepts::ReadMap "read only map" returns the product of the
  3.1522 -  ///values of the two given maps.
  3.1523 -  ///Its \c Key and \c Value are inherited from \c M1.
  3.1524 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  3.1525 -  template<typename M1, typename M2> 
  3.1526 -  class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1527 -    const M1& m1;
  3.1528 -    const M2& m2;
  3.1529 -  public:
  3.1530 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1531 -    typedef typename Parent::Key Key;
  3.1532 -    typedef typename Parent::Value Value;
  3.1533 -
  3.1534 -    ///Constructor
  3.1535 -    MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  3.1536 -    /// \e
  3.1537 -    Value operator[](Key k) const {return m1[k]*m2[k];}
  3.1538 -  };
  3.1539 -  
  3.1540 -  ///Returns a \c MulMap class
  3.1541 -
  3.1542 -  ///This function just returns a \c MulMap class.
  3.1543 -  ///\relates MulMap
  3.1544 -  template<typename M1, typename M2> 
  3.1545 -  inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
  3.1546 -    return MulMap<M1, M2>(m1,m2);
  3.1547 -  }
  3.1548 - 
  3.1549 -  ///Scales a map with a constant.
  3.1550 -
  3.1551 -  ///This \ref concepts::ReadMap "read only map" returns the value of the
  3.1552 -  ///given map multiplied from the left side with a constant value.
  3.1553 -  ///Its \c Key and \c Value are inherited from \c M.
  3.1554 -  ///
  3.1555 -  ///Actually,
  3.1556 -  ///\code
  3.1557 -  ///  ScaleMap<X> sc(x,v);
  3.1558 -  ///\endcode
  3.1559 -  ///is equivalent to
  3.1560 -  ///\code
  3.1561 -  ///  ConstMap<X::Key, X::Value> c_tmp(v);
  3.1562 -  ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
  3.1563 -  ///\endcode
  3.1564 -  ///
  3.1565 -  ///\sa ScaleWriteMap
  3.1566 -  template<typename M, typename C = typename M::Value> 
  3.1567 -  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
  3.1568 -    const M& m;
  3.1569 -    C v;
  3.1570 +  /// \sa ScaleMap
  3.1571 +  template<typename M, typename C = typename M::Value>
  3.1572 +  class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1573 +    M &_m;
  3.1574 +    C _v;
  3.1575    public:
  3.1576      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1577      typedef typename Parent::Key Key;
  3.1578      typedef typename Parent::Value Value;
  3.1579  
  3.1580 -    ///Constructor
  3.1581 +    /// Constructor
  3.1582  
  3.1583 -    ///Constructor.
  3.1584 -    ///\param _m is the undelying map.
  3.1585 -    ///\param _v is the scaling value.
  3.1586 -    ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
  3.1587 +    /// Constructor.
  3.1588 +    /// \param m The undelying map.
  3.1589 +    /// \param v The constant value.
  3.1590 +    ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {}
  3.1591      /// \e
  3.1592 -    Value operator[](Key k) const {return v * m[k];}
  3.1593 +    Value operator[](const Key &k) const { return _v*_m[k]; }
  3.1594 +    /// \e
  3.1595 +    void set(const Key &k, const Value &v) { _m.set(k, v/_v); }
  3.1596    };
  3.1597  
  3.1598 -  ///Scales a map with a constant (ReadWrite version).
  3.1599 +  /// Returns a \ref ScaleMap class
  3.1600  
  3.1601 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
  3.1602 -  ///given map multiplied from the left side with a constant value. It can
  3.1603 -  ///also be used as write map if the \c / operator is defined between
  3.1604 -  ///\c Value and \c C and the given multiplier is not zero.
  3.1605 -  ///Its \c Key and \c Value are inherited from \c M.
  3.1606 +  /// This function just returns a \ref ScaleMap class.
  3.1607    ///
  3.1608 -  ///\sa ScaleMap
  3.1609 -  template<typename M, typename C = typename M::Value> 
  3.1610 -  class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1611 -    M& m;
  3.1612 -    C v;
  3.1613 +  /// For example, if \c m is a map with \c double values and \c v is
  3.1614 +  /// \c double, then <tt>scaleMap(m,v)[x]</tt> will be equal to
  3.1615 +  /// <tt>v*m[x]</tt>.
  3.1616 +  ///
  3.1617 +  /// \relates ScaleMap
  3.1618 +  template<typename M, typename C>
  3.1619 +  inline ScaleMap<M, C> scaleMap(const M &m, const C &v) {
  3.1620 +    return ScaleMap<M, C>(m,v);
  3.1621 +  }
  3.1622 +
  3.1623 +  /// Returns a \ref ScaleWriteMap class
  3.1624 +
  3.1625 +  /// This function just returns a \ref ScaleWriteMap class.
  3.1626 +  ///
  3.1627 +  /// For example, if \c m is a map with \c double values and \c v is
  3.1628 +  /// \c double, then <tt>scaleWriteMap(m,v)[x]</tt> will be equal to
  3.1629 +  /// <tt>v*m[x]</tt>.
  3.1630 +  /// Moreover it makes also possible to write the map.
  3.1631 +  ///
  3.1632 +  /// \relates ScaleWriteMap
  3.1633 +  template<typename M, typename C>
  3.1634 +  inline ScaleWriteMap<M, C> scaleWriteMap(M &m, const C &v) {
  3.1635 +    return ScaleWriteMap<M, C>(m,v);
  3.1636 +  }
  3.1637 +
  3.1638 +
  3.1639 +  /// Negative of a map
  3.1640 +
  3.1641 +  /// This \ref concepts::ReadMap "read-only map" returns the negative
  3.1642 +  /// of the values of the given map (using the unary \c - operator).
  3.1643 +  /// Its \c Key and \c Value are inherited from \c M.
  3.1644 +  ///
  3.1645 +  /// If M::Value is \c int, \c double etc., then
  3.1646 +  /// \code
  3.1647 +  ///   NegMap<M> neg(m);
  3.1648 +  /// \endcode
  3.1649 +  /// is equivalent to
  3.1650 +  /// \code
  3.1651 +  ///   ScaleMap<M> neg(m,-1);
  3.1652 +  /// \endcode
  3.1653 +  ///
  3.1654 +  /// The simplest way of using this map is through the negMap()
  3.1655 +  /// function.
  3.1656 +  ///
  3.1657 +  /// \sa NegWriteMap
  3.1658 +  template<typename M>
  3.1659 +  class NegMap : public MapBase<typename M::Key, typename M::Value> {
  3.1660 +    const M& _m;
  3.1661    public:
  3.1662      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1663      typedef typename Parent::Key Key;
  3.1664      typedef typename Parent::Value Value;
  3.1665  
  3.1666 -    ///Constructor
  3.1667 -
  3.1668 -    ///Constructor.
  3.1669 -    ///\param _m is the undelying map.
  3.1670 -    ///\param _v is the scaling value.
  3.1671 -    ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
  3.1672 +    /// Constructor
  3.1673 +    NegMap(const M &m) : _m(m) {}
  3.1674      /// \e
  3.1675 -    Value operator[](Key k) const {return v * m[k];}
  3.1676 -    /// \e
  3.1677 -    void set(Key k, const Value& c) { m.set(k, c / v);}
  3.1678 -  };
  3.1679 -  
  3.1680 -  ///Returns a \c ScaleMap class
  3.1681 -
  3.1682 -  ///This function just returns a \c ScaleMap class.
  3.1683 -  ///\relates ScaleMap
  3.1684 -  template<typename M, typename C> 
  3.1685 -  inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
  3.1686 -    return ScaleMap<M, C>(m,v);
  3.1687 -  }
  3.1688 -
  3.1689 -  ///Returns a \c ScaleWriteMap class
  3.1690 -
  3.1691 -  ///This function just returns a \c ScaleWriteMap class.
  3.1692 -  ///\relates ScaleWriteMap
  3.1693 -  template<typename M, typename C> 
  3.1694 -  inline ScaleWriteMap<M, C> scaleMap(M &m,const C &v) {
  3.1695 -    return ScaleWriteMap<M, C>(m,v);
  3.1696 -  }
  3.1697 -
  3.1698 -  ///Quotient of two maps
  3.1699 -
  3.1700 -  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
  3.1701 -  ///values of the two given maps.
  3.1702 -  ///Its \c Key and \c Value are inherited from \c M1.
  3.1703 -  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
  3.1704 -  template<typename M1, typename M2> 
  3.1705 -  class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.1706 -    const M1& m1;
  3.1707 -    const M2& m2;
  3.1708 -  public:
  3.1709 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.1710 -    typedef typename Parent::Key Key;
  3.1711 -    typedef typename Parent::Value Value;
  3.1712 -
  3.1713 -    ///Constructor
  3.1714 -    DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  3.1715 -    /// \e
  3.1716 -    Value operator[](Key k) const {return m1[k]/m2[k];}
  3.1717 -  };
  3.1718 -  
  3.1719 -  ///Returns a \c DivMap class
  3.1720 -
  3.1721 -  ///This function just returns a \c DivMap class.
  3.1722 -  ///\relates DivMap
  3.1723 -  template<typename M1, typename M2> 
  3.1724 -  inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
  3.1725 -    return DivMap<M1, M2>(m1,m2);
  3.1726 -  }
  3.1727 -  
  3.1728 -  ///Composition of two maps
  3.1729 -
  3.1730 -  ///This \ref concepts::ReadMap "read only map" returns the composition of
  3.1731 -  ///two given maps.
  3.1732 -  ///That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2,
  3.1733 -  ///then for
  3.1734 -  ///\code
  3.1735 -  ///  ComposeMap<M1, M2> cm(m1,m2);
  3.1736 -  ///\endcode
  3.1737 -  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
  3.1738 -  ///
  3.1739 -  ///Its \c Key is inherited from \c M2 and its \c Value is from \c M1.
  3.1740 -  ///\c M2::Value must be convertible to \c M1::Key.
  3.1741 -  ///
  3.1742 -  ///\sa CombineMap
  3.1743 -  ///
  3.1744 -  ///\todo Check the requirements.
  3.1745 -  template <typename M1, typename M2> 
  3.1746 -  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
  3.1747 -    const M1& m1;
  3.1748 -    const M2& m2;
  3.1749 -  public:
  3.1750 -    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
  3.1751 -    typedef typename Parent::Key Key;
  3.1752 -    typedef typename Parent::Value Value;
  3.1753 -
  3.1754 -    ///Constructor
  3.1755 -    ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
  3.1756 -    
  3.1757 -    /// \e
  3.1758 -
  3.1759 -
  3.1760 -    /// \todo Use the  MapTraits once it is ported.
  3.1761 -    ///
  3.1762 -
  3.1763 -    //typename MapTraits<M1>::ConstReturnValue
  3.1764 -    typename M1::Value
  3.1765 -    operator[](Key k) const {return m1[m2[k]];}
  3.1766 +    Value operator[](const Key &k) const { return -_m[k]; }
  3.1767    };
  3.1768  
  3.1769 -  ///Returns a \c ComposeMap class
  3.1770 +  /// Negative of a map (read-write version)
  3.1771  
  3.1772 -  ///This function just returns a \c ComposeMap class.
  3.1773 -  ///\relates ComposeMap
  3.1774 -  template <typename M1, typename M2> 
  3.1775 -  inline ComposeMap<M1, M2> composeMap(const M1 &m1,const M2 &m2) {
  3.1776 -    return ComposeMap<M1, M2>(m1,m2);
  3.1777 -  }
  3.1778 -  
  3.1779 -  ///Combine of two maps using an STL (binary) functor.
  3.1780 -
  3.1781 -  ///Combine of two maps using an STL (binary) functor.
  3.1782 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the
  3.1783 +  /// negative of the values of the given map (using the unary \c -
  3.1784 +  /// operator).
  3.1785 +  /// Its \c Key and \c Value are inherited from \c M.
  3.1786 +  /// It makes also possible to write the map.
  3.1787    ///
  3.1788 -  ///This \ref concepts::ReadMap "read only map" takes two maps and a
  3.1789 -  ///binary functor and returns the composition of the two
  3.1790 -  ///given maps unsing the functor. 
  3.1791 -  ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
  3.1792 -  ///and \c f is of \c F, then for
  3.1793 -  ///\code
  3.1794 -  ///  CombineMap<M1,M2,F,V> cm(m1,m2,f);
  3.1795 -  ///\endcode
  3.1796 -  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>
  3.1797 +  /// If M::Value is \c int, \c double etc., then
  3.1798 +  /// \code
  3.1799 +  ///   NegWriteMap<M> neg(m);
  3.1800 +  /// \endcode
  3.1801 +  /// is equivalent to
  3.1802 +  /// \code
  3.1803 +  ///   ScaleWriteMap<M> neg(m,-1);
  3.1804 +  /// \endcode
  3.1805    ///
  3.1806 -  ///Its \c Key is inherited from \c M1 and its \c Value is \c V.
  3.1807 -  ///\c M2::Value and \c M1::Value must be convertible to the corresponding
  3.1808 -  ///input parameter of \c F and the return type of \c F must be convertible
  3.1809 -  ///to \c V.
  3.1810 +  /// The simplest way of using this map is through the negWriteMap()
  3.1811 +  /// function.
  3.1812    ///
  3.1813 -  ///\sa ComposeMap
  3.1814 -  ///
  3.1815 -  ///\todo Check the requirements.
  3.1816 -  template<typename M1, typename M2, typename F,
  3.1817 -	   typename V = typename F::result_type> 
  3.1818 -  class CombineMap : public MapBase<typename M1::Key, V> {
  3.1819 -    const M1& m1;
  3.1820 -    const M2& m2;
  3.1821 -    F f;
  3.1822 -  public:
  3.1823 -    typedef MapBase<typename M1::Key, V> Parent;
  3.1824 -    typedef typename Parent::Key Key;
  3.1825 -    typedef typename Parent::Value Value;
  3.1826 -
  3.1827 -    ///Constructor
  3.1828 -    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f = F())
  3.1829 -      : m1(_m1), m2(_m2), f(_f) {};
  3.1830 -    /// \e
  3.1831 -    Value operator[](Key k) const {return f(m1[k],m2[k]);}
  3.1832 -  };
  3.1833 -  
  3.1834 -  ///Returns a \c CombineMap class
  3.1835 -
  3.1836 -  ///This function just returns a \c CombineMap class.
  3.1837 -  ///
  3.1838 -  ///For example if \c m1 and \c m2 are both \c double valued maps, then 
  3.1839 -  ///\code
  3.1840 -  ///combineMap(m1,m2,std::plus<double>())
  3.1841 -  ///\endcode
  3.1842 -  ///is equivalent to
  3.1843 -  ///\code
  3.1844 -  ///addMap(m1,m2)
  3.1845 -  ///\endcode
  3.1846 -  ///
  3.1847 -  ///This function is specialized for adaptable binary function
  3.1848 -  ///classes and C++ functions.
  3.1849 -  ///
  3.1850 -  ///\relates CombineMap
  3.1851 -  template<typename M1, typename M2, typename F, typename V> 
  3.1852 -  inline CombineMap<M1, M2, F, V> 
  3.1853 -  combineMap(const M1& m1,const M2& m2, const F& f) {
  3.1854 -    return CombineMap<M1, M2, F, V>(m1,m2,f);
  3.1855 -  }
  3.1856 -
  3.1857 -  template<typename M1, typename M2, typename F> 
  3.1858 -  inline CombineMap<M1, M2, F, typename F::result_type> 
  3.1859 -  combineMap(const M1& m1, const M2& m2, const F& f) {
  3.1860 -    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
  3.1861 -  }
  3.1862 -
  3.1863 -  template<typename M1, typename M2, typename K1, typename K2, typename V> 
  3.1864 -  inline CombineMap<M1, M2, V (*)(K1, K2), V> 
  3.1865 -  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
  3.1866 -    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
  3.1867 -  }
  3.1868 -
  3.1869 -  ///Negative value of a map
  3.1870 -
  3.1871 -  ///This \ref concepts::ReadMap "read only map" returns the negative
  3.1872 -  ///value of the value returned by the given map.
  3.1873 -  ///Its \c Key and \c Value are inherited from \c M.
  3.1874 -  ///The unary \c - operator must be defined for \c Value, of course.
  3.1875 -  ///
  3.1876 -  ///\sa NegWriteMap
  3.1877 -  template<typename M> 
  3.1878 -  class NegMap : public MapBase<typename M::Key, typename M::Value> {
  3.1879 -    const M& m;
  3.1880 +  /// \sa NegMap
  3.1881 +  template<typename M>
  3.1882 +  class NegWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1883 +    M &_m;
  3.1884    public:
  3.1885      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1886      typedef typename Parent::Key Key;
  3.1887      typedef typename Parent::Value Value;
  3.1888  
  3.1889 -    ///Constructor
  3.1890 -    NegMap(const M &_m) : m(_m) {};
  3.1891 +    /// Constructor
  3.1892 +    NegWriteMap(M &m) : _m(m) {}
  3.1893      /// \e
  3.1894 -    Value operator[](Key k) const {return -m[k];}
  3.1895 +    Value operator[](const Key &k) const { return -_m[k]; }
  3.1896 +    /// \e
  3.1897 +    void set(const Key &k, const Value &v) { _m.set(k, -v); }
  3.1898    };
  3.1899 -  
  3.1900 -  ///Negative value of a map (ReadWrite version)
  3.1901  
  3.1902 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
  3.1903 -  ///value of the value returned by the given map.
  3.1904 -  ///Its \c Key and \c Value are inherited from \c M.
  3.1905 -  ///The unary \c - operator must be defined for \c Value, of course.
  3.1906 +  /// Returns a \ref NegMap class
  3.1907 +
  3.1908 +  /// This function just returns a \ref NegMap class.
  3.1909    ///
  3.1910 -  /// \sa NegMap
  3.1911 -  template<typename M> 
  3.1912 -  class NegWriteMap : public MapBase<typename M::Key, typename M::Value> {
  3.1913 -    M& m;
  3.1914 +  /// For example, if \c m is a map with \c double values, then
  3.1915 +  /// <tt>negMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
  3.1916 +  ///
  3.1917 +  /// \relates NegMap
  3.1918 +  template <typename M>
  3.1919 +  inline NegMap<M> negMap(const M &m) {
  3.1920 +    return NegMap<M>(m);
  3.1921 +  }
  3.1922 +
  3.1923 +  /// Returns a \ref NegWriteMap class
  3.1924 +
  3.1925 +  /// This function just returns a \ref NegWriteMap class.
  3.1926 +  ///
  3.1927 +  /// For example, if \c m is a map with \c double values, then
  3.1928 +  /// <tt>negWriteMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
  3.1929 +  /// Moreover it makes also possible to write the map.
  3.1930 +  ///
  3.1931 +  /// \relates NegWriteMap
  3.1932 +  template <typename M>
  3.1933 +  inline NegWriteMap<M> negWriteMap(M &m) {
  3.1934 +    return NegWriteMap<M>(m);
  3.1935 +  }
  3.1936 +
  3.1937 +
  3.1938 +  /// Absolute value of a map
  3.1939 +
  3.1940 +  /// This \ref concepts::ReadMap "read-only map" returns the absolute
  3.1941 +  /// value of the values of the given map.
  3.1942 +  /// Its \c Key and \c Value are inherited from \c M.
  3.1943 +  /// \c Value must be comparable to \c 0 and the unary \c -
  3.1944 +  /// operator must be defined for it, of course.
  3.1945 +  ///
  3.1946 +  /// The simplest way of using this map is through the absMap()
  3.1947 +  /// function.
  3.1948 +  template<typename M>
  3.1949 +  class AbsMap : public MapBase<typename M::Key, typename M::Value> {
  3.1950 +    const M &_m;
  3.1951    public:
  3.1952      typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1953      typedef typename Parent::Key Key;
  3.1954      typedef typename Parent::Value Value;
  3.1955  
  3.1956 -    ///Constructor
  3.1957 -    NegWriteMap(M &_m) : m(_m) {};
  3.1958 +    /// Constructor
  3.1959 +    AbsMap(const M &m) : _m(m) {}
  3.1960      /// \e
  3.1961 -    Value operator[](Key k) const {return -m[k];}
  3.1962 -    /// \e
  3.1963 -    void set(Key k, const Value& v) { m.set(k, -v); }
  3.1964 -  };
  3.1965 -
  3.1966 -  ///Returns a \c NegMap class
  3.1967 -
  3.1968 -  ///This function just returns a \c NegMap class.
  3.1969 -  ///\relates NegMap
  3.1970 -  template <typename M> 
  3.1971 -  inline NegMap<M> negMap(const M &m) {
  3.1972 -    return NegMap<M>(m);
  3.1973 -  }
  3.1974 -
  3.1975 -  ///Returns a \c NegWriteMap class
  3.1976 -
  3.1977 -  ///This function just returns a \c NegWriteMap class.
  3.1978 -  ///\relates NegWriteMap
  3.1979 -  template <typename M> 
  3.1980 -  inline NegWriteMap<M> negMap(M &m) {
  3.1981 -    return NegWriteMap<M>(m);
  3.1982 -  }
  3.1983 -
  3.1984 -  ///Absolute value of a map
  3.1985 -
  3.1986 -  ///This \ref concepts::ReadMap "read only map" returns the absolute value
  3.1987 -  ///of the value returned by the given map.
  3.1988 -  ///Its \c Key and \c Value are inherited from \c M. 
  3.1989 -  ///\c Value must be comparable to \c 0 and the unary \c -
  3.1990 -  ///operator must be defined for it, of course.
  3.1991 -  template<typename M> 
  3.1992 -  class AbsMap : public MapBase<typename M::Key, typename M::Value> {
  3.1993 -    const M& m;
  3.1994 -  public:
  3.1995 -    typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.1996 -    typedef typename Parent::Key Key;
  3.1997 -    typedef typename Parent::Value Value;
  3.1998 -
  3.1999 -    ///Constructor
  3.2000 -    AbsMap(const M &_m) : m(_m) {};
  3.2001 -    /// \e
  3.2002 -    Value operator[](Key k) const {
  3.2003 -      Value tmp = m[k]; 
  3.2004 +    Value operator[](const Key &k) const {
  3.2005 +      Value tmp = _m[k];
  3.2006        return tmp >= 0 ? tmp : -tmp;
  3.2007      }
  3.2008  
  3.2009    };
  3.2010 -  
  3.2011 -  ///Returns an \c AbsMap class
  3.2012  
  3.2013 -  ///This function just returns an \c AbsMap class.
  3.2014 -  ///\relates AbsMap
  3.2015 -  template<typename M> 
  3.2016 +  /// Returns an \ref AbsMap class
  3.2017 +
  3.2018 +  /// This function just returns an \ref AbsMap class.
  3.2019 +  ///
  3.2020 +  /// For example, if \c m is a map with \c double values, then
  3.2021 +  /// <tt>absMap(m)[x]</tt> will be equal to <tt>m[x]</tt> if
  3.2022 +  /// it is positive or zero and <tt>-m[x]</tt> if <tt>m[x]</tt> is
  3.2023 +  /// negative.
  3.2024 +  ///
  3.2025 +  /// \relates AbsMap
  3.2026 +  template<typename M>
  3.2027    inline AbsMap<M> absMap(const M &m) {
  3.2028      return AbsMap<M>(m);
  3.2029    }
  3.2030  
  3.2031 -  ///Converts an STL style functor to a map
  3.2032 +  /// @}
  3.2033 +  
  3.2034 +  // Logical maps and map adaptors:
  3.2035  
  3.2036 -  ///This \ref concepts::ReadMap "read only map" returns the value
  3.2037 -  ///of a given functor.
  3.2038 +  /// \addtogroup maps
  3.2039 +  /// @{
  3.2040 +
  3.2041 +  /// Constant \c true map.
  3.2042 +
  3.2043 +  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
  3.2044 +  /// each key.
  3.2045    ///
  3.2046 -  ///Template parameters \c K and \c V will become its
  3.2047 -  ///\c Key and \c Value. 
  3.2048 -  ///In most cases they have to be given explicitly because a 
  3.2049 -  ///functor typically does not provide \c argument_type and 
  3.2050 -  ///\c result_type typedefs.
  3.2051 +  /// Note that
  3.2052 +  /// \code
  3.2053 +  ///   TrueMap<K> tm;
  3.2054 +  /// \endcode
  3.2055 +  /// is equivalent to
  3.2056 +  /// \code
  3.2057 +  ///   ConstMap<K,bool> tm(true);
  3.2058 +  /// \endcode
  3.2059    ///
  3.2060 -  ///Parameter \c F is the type of the used functor.
  3.2061 -  ///
  3.2062 -  ///\sa MapFunctor
  3.2063 -  template<typename F, 
  3.2064 -	   typename K = typename F::argument_type, 
  3.2065 -	   typename V = typename F::result_type> 
  3.2066 -  class FunctorMap : public MapBase<K, V> {
  3.2067 -    F f;
  3.2068 +  /// \sa FalseMap
  3.2069 +  /// \sa ConstMap
  3.2070 +  template <typename K>
  3.2071 +  class TrueMap : public MapBase<K, bool> {
  3.2072    public:
  3.2073 -    typedef MapBase<K, V> Parent;
  3.2074 +    typedef MapBase<K, bool> Parent;
  3.2075      typedef typename Parent::Key Key;
  3.2076      typedef typename Parent::Value Value;
  3.2077  
  3.2078 -    ///Constructor
  3.2079 -    FunctorMap(const F &_f = F()) : f(_f) {}
  3.2080 -    /// \e
  3.2081 -    Value operator[](Key k) const { return f(k);}
  3.2082 +    /// Gives back \c true.
  3.2083 +    Value operator[](const Key&) const { return true; }
  3.2084    };
  3.2085 -  
  3.2086 -  ///Returns a \c FunctorMap class
  3.2087  
  3.2088 -  ///This function just returns a \c FunctorMap class.
  3.2089 -  ///
  3.2090 -  ///This function is specialized for adaptable binary function
  3.2091 -  ///classes and C++ functions.
  3.2092 -  ///
  3.2093 -  ///\relates FunctorMap
  3.2094 -  template<typename K, typename V, typename F> inline 
  3.2095 -  FunctorMap<F, K, V> functorMap(const F &f) {
  3.2096 -    return FunctorMap<F, K, V>(f);
  3.2097 +  /// Returns a \ref TrueMap class
  3.2098 +
  3.2099 +  /// This function just returns a \ref TrueMap class.
  3.2100 +  /// \relates TrueMap
  3.2101 +  template<typename K>
  3.2102 +  inline TrueMap<K> trueMap() {
  3.2103 +    return TrueMap<K>();
  3.2104    }
  3.2105  
  3.2106 -  template <typename F> inline 
  3.2107 -  FunctorMap<F, typename F::argument_type, typename F::result_type> 
  3.2108 -  functorMap(const F &f) {
  3.2109 -    return FunctorMap<F, typename F::argument_type, 
  3.2110 -      typename F::result_type>(f);
  3.2111 -  }
  3.2112  
  3.2113 -  template <typename K, typename V> inline 
  3.2114 -  FunctorMap<V (*)(K), K, V> functorMap(V (*f)(K)) {
  3.2115 -    return FunctorMap<V (*)(K), K, V>(f);
  3.2116 -  }
  3.2117 +  /// Constant \c false map.
  3.2118  
  3.2119 -
  3.2120 -  ///Converts a map to an STL style (unary) functor
  3.2121 -
  3.2122 -  ///This class Converts a map to an STL style (unary) functor.
  3.2123 -  ///That is it provides an <tt>operator()</tt> to read its values.
  3.2124 +  /// This \ref concepts::ReadMap "read-only map" assigns \c false to
  3.2125 +  /// each key.
  3.2126    ///
  3.2127 -  ///For the sake of convenience it also works as
  3.2128 -  ///a ususal \ref concepts::ReadMap "readable map",
  3.2129 -  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
  3.2130 +  /// Note that
  3.2131 +  /// \code
  3.2132 +  ///   FalseMap<K> fm;
  3.2133 +  /// \endcode
  3.2134 +  /// is equivalent to
  3.2135 +  /// \code
  3.2136 +  ///   ConstMap<K,bool> fm(false);
  3.2137 +  /// \endcode
  3.2138    ///
  3.2139 -  ///\sa FunctorMap
  3.2140 -  template <typename M> 
  3.2141 -  class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
  3.2142 -    const M& m;
  3.2143 +  /// \sa TrueMap
  3.2144 +  /// \sa ConstMap
  3.2145 +  template <typename K>
  3.2146 +  class FalseMap : public MapBase<K, bool> {
  3.2147    public:
  3.2148 -    typedef MapBase<typename M::Key, typename M::Value> Parent;
  3.2149 +    typedef MapBase<K, bool> Parent;
  3.2150      typedef typename Parent::Key Key;
  3.2151      typedef typename Parent::Value Value;
  3.2152  
  3.2153 -    typedef typename M::Key argument_type;
  3.2154 -    typedef typename M::Value result_type;
  3.2155 +    /// Gives back \c false.
  3.2156 +    Value operator[](const Key&) const { return false; }
  3.2157 +  };
  3.2158  
  3.2159 -    ///Constructor
  3.2160 -    MapFunctor(const M &_m) : m(_m) {};
  3.2161 -    ///\e
  3.2162 -    Value operator()(Key k) const {return m[k];}
  3.2163 -    ///\e
  3.2164 -    Value operator[](Key k) const {return m[k];}
  3.2165 -  };
  3.2166 -  
  3.2167 -  ///Returns a \c MapFunctor class
  3.2168 +  /// Returns a \ref FalseMap class
  3.2169  
  3.2170 -  ///This function just returns a \c MapFunctor class.
  3.2171 -  ///\relates MapFunctor
  3.2172 -  template<typename M> 
  3.2173 -  inline MapFunctor<M> mapFunctor(const M &m) {
  3.2174 -    return MapFunctor<M>(m);
  3.2175 +  /// This function just returns a \ref FalseMap class.
  3.2176 +  /// \relates FalseMap
  3.2177 +  template<typename K>
  3.2178 +  inline FalseMap<K> falseMap() {
  3.2179 +    return FalseMap<K>();
  3.2180    }
  3.2181  
  3.2182 -  ///Just readable version of \ref ForkWriteMap
  3.2183 +  /// @}
  3.2184  
  3.2185 -  ///This map has two \ref concepts::ReadMap "readable map"
  3.2186 -  ///parameters and each read request will be passed just to the
  3.2187 -  ///first map. This class is the just readable map type of \c ForkWriteMap.
  3.2188 +  /// \addtogroup map_adaptors
  3.2189 +  /// @{
  3.2190 +
  3.2191 +  /// Logical 'and' of two maps
  3.2192 +
  3.2193 +  /// This \ref concepts::ReadMap "read-only map" returns the logical
  3.2194 +  /// 'and' of the values of the two given maps.
  3.2195 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
  3.2196 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
  3.2197    ///
  3.2198 -  ///The \c Key and \c Value are inherited from \c M1.
  3.2199 -  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
  3.2200 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.2201 +  /// \code
  3.2202 +  ///   AndMap<M1,M2> am(m1,m2);
  3.2203 +  /// \endcode
  3.2204 +  /// <tt>am[x]</tt> will be equal to <tt>m1[x]&&m2[x]</tt>.
  3.2205    ///
  3.2206 -  ///\sa ForkWriteMap
  3.2207 +  /// The simplest way of using this map is through the andMap()
  3.2208 +  /// function.
  3.2209    ///
  3.2210 -  /// \todo Why is it needed?
  3.2211 -  template<typename  M1, typename M2> 
  3.2212 -  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.2213 -    const M1& m1;
  3.2214 -    const M2& m2;
  3.2215 +  /// \sa OrMap
  3.2216 +  /// \sa NotMap, NotWriteMap
  3.2217 +  template<typename M1, typename M2>
  3.2218 +  class AndMap : public MapBase<typename M1::Key, bool> {
  3.2219 +    const M1 &_m1;
  3.2220 +    const M2 &_m2;
  3.2221    public:
  3.2222 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.2223 +    typedef MapBase<typename M1::Key, bool> Parent;
  3.2224      typedef typename Parent::Key Key;
  3.2225      typedef typename Parent::Value Value;
  3.2226  
  3.2227 -    ///Constructor
  3.2228 -    ForkMap(const M1 &_m1, const M2 &_m2) : m1(_m1), m2(_m2) {};
  3.2229 +    /// Constructor
  3.2230 +    AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  3.2231      /// \e
  3.2232 -    Value operator[](Key k) const {return m1[k];}
  3.2233 +    Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; }
  3.2234    };
  3.2235  
  3.2236 +  /// Returns an \ref AndMap class
  3.2237  
  3.2238 -  ///Applies all map setting operations to two maps
  3.2239 +  /// This function just returns an \ref AndMap class.
  3.2240 +  ///
  3.2241 +  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
  3.2242 +  /// then <tt>andMap(m1,m2)[x]</tt> will be equal to
  3.2243 +  /// <tt>m1[x]&&m2[x]</tt>.
  3.2244 +  ///
  3.2245 +  /// \relates AndMap
  3.2246 +  template<typename M1, typename M2>
  3.2247 +  inline AndMap<M1, M2> andMap(const M1 &m1, const M2 &m2) {
  3.2248 +    return AndMap<M1, M2>(m1,m2);
  3.2249 +  }
  3.2250  
  3.2251 -  ///This map has two \ref concepts::WriteMap "writable map"
  3.2252 -  ///parameters and each write request will be passed to both of them.
  3.2253 -  ///If \c M1 is also \ref concepts::ReadMap "readable",
  3.2254 -  ///then the read operations will return the
  3.2255 -  ///corresponding values of \c M1.
  3.2256 +
  3.2257 +  /// Logical 'or' of two maps
  3.2258 +
  3.2259 +  /// This \ref concepts::ReadMap "read-only map" returns the logical
  3.2260 +  /// 'or' of the values of the two given maps.
  3.2261 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
  3.2262 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
  3.2263    ///
  3.2264 -  ///The \c Key and \c Value are inherited from \c M1.
  3.2265 -  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
  3.2266 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.2267 +  /// \code
  3.2268 +  ///   OrMap<M1,M2> om(m1,m2);
  3.2269 +  /// \endcode
  3.2270 +  /// <tt>om[x]</tt> will be equal to <tt>m1[x]||m2[x]</tt>.
  3.2271    ///
  3.2272 -  ///\sa ForkMap
  3.2273 -  template<typename  M1, typename M2> 
  3.2274 -  class ForkWriteMap : public MapBase<typename M1::Key, typename M1::Value> {
  3.2275 -    M1& m1;
  3.2276 -    M2& m2;
  3.2277 +  /// The simplest way of using this map is through the orMap()
  3.2278 +  /// function.
  3.2279 +  ///
  3.2280 +  /// \sa AndMap
  3.2281 +  /// \sa NotMap, NotWriteMap
  3.2282 +  template<typename M1, typename M2>
  3.2283 +  class OrMap : public MapBase<typename M1::Key, bool> {
  3.2284 +    const M1 &_m1;
  3.2285 +    const M2 &_m2;
  3.2286    public:
  3.2287 -    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
  3.2288 +    typedef MapBase<typename M1::Key, bool> Parent;
  3.2289      typedef typename Parent::Key Key;
  3.2290      typedef typename Parent::Value Value;
  3.2291  
  3.2292 -    ///Constructor
  3.2293 -    ForkWriteMap(M1 &_m1, M2 &_m2) : m1(_m1), m2(_m2) {};
  3.2294 -    ///\e
  3.2295 -    Value operator[](Key k) const {return m1[k];}
  3.2296 -    ///\e
  3.2297 -    void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);}
  3.2298 +    /// Constructor
  3.2299 +    OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  3.2300 +    /// \e
  3.2301 +    Value operator[](const Key &k) const { return _m1[k]||_m2[k]; }
  3.2302    };
  3.2303 -  
  3.2304 -  ///Returns a \c ForkMap class
  3.2305  
  3.2306 -  ///This function just returns a \c ForkMap class.
  3.2307 -  ///\relates ForkMap
  3.2308 -  template <typename M1, typename M2> 
  3.2309 -  inline ForkMap<M1, M2> forkMap(const M1 &m1, const M2 &m2) {
  3.2310 -    return ForkMap<M1, M2>(m1,m2);
  3.2311 +  /// Returns an \ref OrMap class
  3.2312 +
  3.2313 +  /// This function just returns an \ref OrMap class.
  3.2314 +  ///
  3.2315 +  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
  3.2316 +  /// then <tt>orMap(m1,m2)[x]</tt> will be equal to
  3.2317 +  /// <tt>m1[x]||m2[x]</tt>.
  3.2318 +  ///
  3.2319 +  /// \relates OrMap
  3.2320 +  template<typename M1, typename M2>
  3.2321 +  inline OrMap<M1, M2> orMap(const M1 &m1, const M2 &m2) {
  3.2322 +    return OrMap<M1, M2>(m1,m2);
  3.2323    }
  3.2324  
  3.2325 -  ///Returns a \c ForkWriteMap class
  3.2326  
  3.2327 -  ///This function just returns a \c ForkWriteMap class.
  3.2328 -  ///\relates ForkWriteMap
  3.2329 -  template <typename M1, typename M2> 
  3.2330 -  inline ForkWriteMap<M1, M2> forkMap(M1 &m1, M2 &m2) {
  3.2331 -    return ForkWriteMap<M1, M2>(m1,m2);
  3.2332 -  }
  3.2333 +  /// Logical 'not' of a map
  3.2334  
  3.2335 -
  3.2336 -  
  3.2337 -  /* ************* BOOL MAPS ******************* */
  3.2338 -  
  3.2339 -  ///Logical 'not' of a map
  3.2340 -  
  3.2341 -  ///This bool \ref concepts::ReadMap "read only map" returns the 
  3.2342 -  ///logical negation of the value returned by the given map.
  3.2343 -  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
  3.2344 +  /// This \ref concepts::ReadMap "read-only map" returns the logical
  3.2345 +  /// negation of the values of the given map.
  3.2346 +  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
  3.2347    ///
  3.2348 -  ///\sa NotWriteMap
  3.2349 -  template <typename M> 
  3.2350 +  /// The simplest way of using this map is through the notMap()
  3.2351 +  /// function.
  3.2352 +  ///
  3.2353 +  /// \sa NotWriteMap
  3.2354 +  template <typename M>
  3.2355    class NotMap : public MapBase<typename M::Key, bool> {
  3.2356 -    const M& m;
  3.2357 +    const M &_m;
  3.2358    public:
  3.2359      typedef MapBase<typename M::Key, bool> Parent;
  3.2360      typedef typename Parent::Key Key;
  3.2361      typedef typename Parent::Value Value;
  3.2362  
  3.2363      /// Constructor
  3.2364 -    NotMap(const M &_m) : m(_m) {};
  3.2365 -    ///\e
  3.2366 -    Value operator[](Key k) const {return !m[k];}
  3.2367 +    NotMap(const M &m) : _m(m) {}
  3.2368 +    /// \e
  3.2369 +    Value operator[](const Key &k) const { return !_m[k]; }
  3.2370    };
  3.2371  
  3.2372 -  ///Logical 'not' of a map (ReadWrie version)
  3.2373 -  
  3.2374 -  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
  3.2375 -  ///logical negation of the value returned by the given map. When it is set,
  3.2376 -  ///the opposite value is set to the original map.
  3.2377 -  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
  3.2378 +  /// Logical 'not' of a map (read-write version)
  3.2379 +
  3.2380 +  /// This \ref concepts::ReadWriteMap "read-write map" returns the
  3.2381 +  /// logical negation of the values of the given map.
  3.2382 +  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
  3.2383 +  /// It makes also possible to write the map. When a value is set,
  3.2384 +  /// the opposite value is set to the original map.
  3.2385    ///
  3.2386 -  ///\sa NotMap
  3.2387 -  template <typename M> 
  3.2388 +  /// The simplest way of using this map is through the notWriteMap()
  3.2389 +  /// function.
  3.2390 +  ///
  3.2391 +  /// \sa NotMap
  3.2392 +  template <typename M>
  3.2393    class NotWriteMap : public MapBase<typename M::Key, bool> {
  3.2394 -    M& m;
  3.2395 +    M &_m;
  3.2396    public:
  3.2397      typedef MapBase<typename M::Key, bool> Parent;
  3.2398      typedef typename Parent::Key Key;
  3.2399      typedef typename Parent::Value Value;
  3.2400  
  3.2401      /// Constructor
  3.2402 -    NotWriteMap(M &_m) : m(_m) {};
  3.2403 -    ///\e
  3.2404 -    Value operator[](Key k) const {return !m[k];}
  3.2405 -    ///\e
  3.2406 -    void set(Key k, bool v) { m.set(k, !v); }
  3.2407 +    NotWriteMap(M &m) : _m(m) {}
  3.2408 +    /// \e
  3.2409 +    Value operator[](const Key &k) const { return !_m[k]; }
  3.2410 +    /// \e
  3.2411 +    void set(const Key &k, bool v) { _m.set(k, !v); }
  3.2412    };
  3.2413 -  
  3.2414 -  ///Returns a \c NotMap class
  3.2415 -  
  3.2416 -  ///This function just returns a \c NotMap class.
  3.2417 -  ///\relates NotMap
  3.2418 -  template <typename M> 
  3.2419 +
  3.2420 +  /// Returns a \ref NotMap class
  3.2421 +
  3.2422 +  /// This function just returns a \ref NotMap class.
  3.2423 +  ///
  3.2424 +  /// For example, if \c m is a map with \c bool values, then
  3.2425 +  /// <tt>notMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
  3.2426 +  ///
  3.2427 +  /// \relates NotMap
  3.2428 +  template <typename M>
  3.2429    inline NotMap<M> notMap(const M &m) {
  3.2430      return NotMap<M>(m);
  3.2431    }
  3.2432 -  
  3.2433 -  ///Returns a \c NotWriteMap class
  3.2434 -  
  3.2435 -  ///This function just returns a \c NotWriteMap class.
  3.2436 -  ///\relates NotWriteMap
  3.2437 -  template <typename M> 
  3.2438 -  inline NotWriteMap<M> notMap(M &m) {
  3.2439 +
  3.2440 +  /// Returns a \ref NotWriteMap class
  3.2441 +
  3.2442 +  /// This function just returns a \ref NotWriteMap class.
  3.2443 +  ///
  3.2444 +  /// For example, if \c m is a map with \c bool values, then
  3.2445 +  /// <tt>notWriteMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
  3.2446 +  /// Moreover it makes also possible to write the map.
  3.2447 +  ///
  3.2448 +  /// \relates NotWriteMap
  3.2449 +  template <typename M>
  3.2450 +  inline NotWriteMap<M> notWriteMap(M &m) {
  3.2451      return NotWriteMap<M>(m);
  3.2452    }
  3.2453  
  3.2454 -  namespace _maps_bits {
  3.2455  
  3.2456 -    template <typename Value>
  3.2457 -    struct Identity {
  3.2458 -      typedef Value argument_type;
  3.2459 -      typedef Value result_type;
  3.2460 -      Value operator()(const Value& val) const {
  3.2461 -	return val;
  3.2462 -      }
  3.2463 -    };
  3.2464 +  /// Combination of two maps using the \c == operator
  3.2465  
  3.2466 -    template <typename _Iterator, typename Enable = void>
  3.2467 -    struct IteratorTraits {
  3.2468 -      typedef typename std::iterator_traits<_Iterator>::value_type Value;
  3.2469 -    };
  3.2470 -
  3.2471 -    template <typename _Iterator>
  3.2472 -    struct IteratorTraits<_Iterator,
  3.2473 -      typename exists<typename _Iterator::container_type>::type> 
  3.2474 -    {
  3.2475 -      typedef typename _Iterator::container_type::value_type Value;
  3.2476 -    };
  3.2477 -
  3.2478 -  }
  3.2479 -  
  3.2480 -
  3.2481 -  /// \brief Writable bool map for logging each \c true assigned element
  3.2482 +  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
  3.2483 +  /// the keys for which the corresponding values of the two maps are
  3.2484 +  /// equal.
  3.2485 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
  3.2486 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
  3.2487    ///
  3.2488 -  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging 
  3.2489 -  /// each \c true assigned element, i.e it copies all the keys set 
  3.2490 -  /// to \c true to the given iterator.
  3.2491 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.2492 +  /// \code
  3.2493 +  ///   EqualMap<M1,M2> em(m1,m2);
  3.2494 +  /// \endcode
  3.2495 +  /// <tt>em[x]</tt> will be equal to <tt>m1[x]==m2[x]</tt>.
  3.2496    ///
  3.2497 -  /// \note The container of the iterator should contain space 
  3.2498 -  /// for each element.
  3.2499 +  /// The simplest way of using this map is through the equalMap()
  3.2500 +  /// function.
  3.2501    ///
  3.2502 -  /// The following example shows how you can write the edges found by 
  3.2503 -  /// the \ref Prim algorithm directly to the standard output.
  3.2504 -  ///\code
  3.2505 -  /// typedef IdMap<Graph, Edge> EdgeIdMap;
  3.2506 -  /// EdgeIdMap edgeId(graph);
  3.2507 -  ///
  3.2508 -  /// typedef MapFunctor<EdgeIdMap> EdgeIdFunctor;
  3.2509 -  /// EdgeIdFunctor edgeIdFunctor(edgeId);
  3.2510 -  ///
  3.2511 -  /// StoreBoolMap<ostream_iterator<int>, EdgeIdFunctor> 
  3.2512 -  ///   writerMap(ostream_iterator<int>(cout, " "), edgeIdFunctor);
  3.2513 -  ///
  3.2514 -  /// prim(graph, cost, writerMap);
  3.2515 -  ///\endcode
  3.2516 -  ///
  3.2517 -  ///\sa BackInserterBoolMap 
  3.2518 -  ///\sa FrontInserterBoolMap 
  3.2519 -  ///\sa InserterBoolMap 
  3.2520 -  ///
  3.2521 -  ///\todo Revise the name of this class and the related ones.
  3.2522 -  template <typename _Iterator, 
  3.2523 -            typename _Functor =
  3.2524 -            _maps_bits::Identity<typename _maps_bits::
  3.2525 -                                 IteratorTraits<_Iterator>::Value> >
  3.2526 -  class StoreBoolMap {
  3.2527 +  /// \sa LessMap
  3.2528 +  template<typename M1, typename M2>
  3.2529 +  class EqualMap : public MapBase<typename M1::Key, bool> {
  3.2530 +    const M1 &_m1;
  3.2531 +    const M2 &_m2;
  3.2532    public:
  3.2533 -    typedef _Iterator Iterator;
  3.2534 -
  3.2535 -    typedef typename _Functor::argument_type Key;
  3.2536 -    typedef bool Value;
  3.2537 -
  3.2538 -    typedef _Functor Functor;
  3.2539 +    typedef MapBase<typename M1::Key, bool> Parent;
  3.2540 +    typedef typename Parent::Key Key;
  3.2541 +    typedef typename Parent::Value Value;
  3.2542  
  3.2543      /// Constructor
  3.2544 -    StoreBoolMap(Iterator it, const Functor& functor = Functor()) 
  3.2545 -      : _begin(it), _end(it), _functor(functor) {}
  3.2546 -
  3.2547 -    /// Gives back the given iterator set for the first key
  3.2548 -    Iterator begin() const {
  3.2549 -      return _begin;
  3.2550 -    }
  3.2551 - 
  3.2552 -    /// Gives back the the 'after the last' iterator
  3.2553 -    Iterator end() const {
  3.2554 -      return _end;
  3.2555 -    }
  3.2556 -
  3.2557 -    /// The \c set function of the map
  3.2558 -    void set(const Key& key, Value value) const {
  3.2559 -      if (value) {
  3.2560 -	*_end++ = _functor(key);
  3.2561 -      }
  3.2562 -    }
  3.2563 -    
  3.2564 -  private:
  3.2565 -    Iterator _begin;
  3.2566 -    mutable Iterator _end;
  3.2567 -    Functor _functor;
  3.2568 +    EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  3.2569 +    /// \e
  3.2570 +    Value operator[](const Key &k) const { return _m1[k]==_m2[k]; }
  3.2571    };
  3.2572  
  3.2573 -  /// \brief Writable bool map for logging each \c true assigned element in 
  3.2574 -  /// a back insertable container.
  3.2575 +  /// Returns an \ref EqualMap class
  3.2576 +
  3.2577 +  /// This function just returns an \ref EqualMap class.
  3.2578    ///
  3.2579 -  /// Writable bool map for logging each \c true assigned element by pushing
  3.2580 -  /// them into a back insertable container.
  3.2581 -  /// It can be used to retrieve the items into a standard
  3.2582 -  /// container. The next example shows how you can store the
  3.2583 -  /// edges found by the Prim algorithm in a vector.
  3.2584 +  /// For example, if \c m1 and \c m2 are maps with keys and values of
  3.2585 +  /// the same type, then <tt>equalMap(m1,m2)[x]</tt> will be equal to
  3.2586 +  /// <tt>m1[x]==m2[x]</tt>.
  3.2587    ///
  3.2588 -  ///\code
  3.2589 -  /// vector<Edge> span_tree_edges;
  3.2590 -  /// BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges);
  3.2591 -  /// prim(graph, cost, inserter_map);
  3.2592 -  ///\endcode
  3.2593 +  /// \relates EqualMap
  3.2594 +  template<typename M1, typename M2>
  3.2595 +  inline EqualMap<M1, M2> equalMap(const M1 &m1, const M2 &m2) {
  3.2596 +    return EqualMap<M1, M2>(m1,m2);
  3.2597 +  }
  3.2598 +
  3.2599 +
  3.2600 +  /// Combination of two maps using the \c < operator
  3.2601 +
  3.2602 +  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
  3.2603 +  /// the keys for which the corresponding value of the first map is
  3.2604 +  /// less then the value of the second map.
  3.2605 +  /// Its \c Key type is inherited from \c M1 and its \c Value type is
  3.2606 +  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
  3.2607    ///
  3.2608 -  ///\sa StoreBoolMap
  3.2609 -  ///\sa FrontInserterBoolMap
  3.2610 -  ///\sa InserterBoolMap
  3.2611 -  template <typename Container,
  3.2612 -            typename Functor =
  3.2613 -            _maps_bits::Identity<typename Container::value_type> >
  3.2614 -  class BackInserterBoolMap {
  3.2615 +  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
  3.2616 +  /// \code
  3.2617 +  ///   LessMap<M1,M2> lm(m1,m2);
  3.2618 +  /// \endcode
  3.2619 +  /// <tt>lm[x]</tt> will be equal to <tt>m1[x]<m2[x]</tt>.
  3.2620 +  ///
  3.2621 +  /// The simplest way of using this map is through the lessMap()
  3.2622 +  /// function.
  3.2623 +  ///
  3.2624 +  /// \sa EqualMap
  3.2625 +  template<typename M1, typename M2>
  3.2626 +  class LessMap : public MapBase<typename M1::Key, bool> {
  3.2627 +    const M1 &_m1;
  3.2628 +    const M2 &_m2;
  3.2629    public:
  3.2630 -    typedef typename Functor::argument_type Key;
  3.2631 -    typedef bool Value;
  3.2632 +    typedef MapBase<typename M1::Key, bool> Parent;
  3.2633 +    typedef typename Parent::Key Key;
  3.2634 +    typedef typename Parent::Value Value;
  3.2635  
  3.2636      /// Constructor
  3.2637 -    BackInserterBoolMap(Container& _container, 
  3.2638 -                        const Functor& _functor = Functor()) 
  3.2639 -      : container(_container), functor(_functor) {}
  3.2640 -
  3.2641 -    /// The \c set function of the map
  3.2642 -    void set(const Key& key, Value value) {
  3.2643 -      if (value) {
  3.2644 -	container.push_back(functor(key));
  3.2645 -      }
  3.2646 -    }
  3.2647 -    
  3.2648 -  private:
  3.2649 -    Container& container;
  3.2650 -    Functor functor;
  3.2651 +    LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
  3.2652 +    /// \e
  3.2653 +    Value operator[](const Key &k) const { return _m1[k]<_m2[k]; }
  3.2654    };
  3.2655  
  3.2656 -  /// \brief Writable bool map for logging each \c true assigned element in 
  3.2657 -  /// a front insertable container.
  3.2658 +  /// Returns an \ref LessMap class
  3.2659 +
  3.2660 +  /// This function just returns an \ref LessMap class.
  3.2661    ///
  3.2662 -  /// Writable bool map for logging each \c true assigned element by pushing
  3.2663 -  /// them into a front insertable container.
  3.2664 -  /// It can be used to retrieve the items into a standard
  3.2665 -  /// container. For example see \ref BackInserterBoolMap.
  3.2666 +  /// For example, if \c m1 and \c m2 are maps with keys and values of
  3.2667 +  /// the same type, then <tt>lessMap(m1,m2)[x]</tt> will be equal to
  3.2668 +  /// <tt>m1[x]<m2[x]</tt>.
  3.2669    ///
  3.2670 -  ///\sa BackInserterBoolMap
  3.2671 -  ///\sa InserterBoolMap
  3.2672 -  template <typename Container,
  3.2673 -            typename Functor =
  3.2674 -            _maps_bits::Identity<typename Container::value_type> >
  3.2675 -  class FrontInserterBoolMap {
  3.2676 -  public:
  3.2677 -    typedef typename Functor::argument_type Key;
  3.2678 -    typedef bool Value;
  3.2679 -
  3.2680 -    /// Constructor
  3.2681 -    FrontInserterBoolMap(Container& _container,
  3.2682 -                         const Functor& _functor = Functor()) 
  3.2683 -      : container(_container), functor(_functor) {}
  3.2684 -
  3.2685 -    /// The \c set function of the map
  3.2686 -    void set(const Key& key, Value value) {
  3.2687 -      if (value) {
  3.2688 -	container.push_front(functor(key));
  3.2689 -      }
  3.2690 -    }
  3.2691 -    
  3.2692 -  private:
  3.2693 -    Container& container;    
  3.2694 -    Functor functor;
  3.2695 -  };
  3.2696 -
  3.2697 -  /// \brief Writable bool map for storing each \c true assigned element in 
  3.2698 -  /// an insertable container.
  3.2699 -  ///
  3.2700 -  /// Writable bool map for storing each \c true assigned element in an 
  3.2701 -  /// insertable container. It will insert all the keys set to \c true into
  3.2702 -  /// the container.
  3.2703 -  ///
  3.2704 -  /// For example, if you want to store the cut arcs of the strongly
  3.2705 -  /// connected components in a set you can use the next code:
  3.2706 -  ///
  3.2707 -  ///\code
  3.2708 -  /// set<Arc> cut_arcs;
  3.2709 -  /// InserterBoolMap<set<Arc> > inserter_map(cut_arcs);
  3.2710 -  /// stronglyConnectedCutArcs(digraph, cost, inserter_map);
  3.2711 -  ///\endcode
  3.2712 -  ///
  3.2713 -  ///\sa BackInserterBoolMap
  3.2714 -  ///\sa FrontInserterBoolMap
  3.2715 -  template <typename Container,
  3.2716 -            typename Functor =
  3.2717 -            _maps_bits::Identity<typename Container::value_type> >
  3.2718 -  class InserterBoolMap {
  3.2719 -  public:
  3.2720 -    typedef typename Container::value_type Key;
  3.2721 -    typedef bool Value;
  3.2722 -
  3.2723 -    /// Constructor with specified iterator
  3.2724 -    
  3.2725 -    /// Constructor with specified iterator.
  3.2726 -    /// \param _container The container for storing the elements.
  3.2727 -    /// \param _it The elements will be inserted before this iterator.
  3.2728 -    /// \param _functor The functor that is used when an element is stored.
  3.2729 -    InserterBoolMap(Container& _container, typename Container::iterator _it,
  3.2730 -                    const Functor& _functor = Functor()) 
  3.2731 -      : container(_container), it(_it), functor(_functor) {}
  3.2732 -
  3.2733 -    /// Constructor
  3.2734 -
  3.2735 -    /// Constructor without specified iterator.
  3.2736 -    /// The elements will be inserted before <tt>_container.end()</tt>.
  3.2737 -    /// \param _container The container for storing the elements.
  3.2738 -    /// \param _functor The functor that is used when an element is stored.
  3.2739 -    InserterBoolMap(Container& _container, const Functor& _functor = Functor())
  3.2740 -      : container(_container), it(_container.end()), functor(_functor) {}
  3.2741 -
  3.2742 -    /// The \c set function of the map
  3.2743 -    void set(const Key& key, Value value) {
  3.2744 -      if (value) {
  3.2745 -	it = container.insert(it, functor(key));
  3.2746 -        ++it;
  3.2747 -      }
  3.2748 -    }
  3.2749 -    
  3.2750 -  private:
  3.2751 -    Container& container;
  3.2752 -    typename Container::iterator it;
  3.2753 -    Functor functor;
  3.2754 -  };
  3.2755 -
  3.2756 -  /// \brief Writable bool map for filling each \c true assigned element with a 
  3.2757 -  /// given value.
  3.2758 -  ///
  3.2759 -  /// Writable bool map for filling each \c true assigned element with a 
  3.2760 -  /// given value. The value can set the container.
  3.2761 -  ///
  3.2762 -  /// The following code finds the connected components of a graph
  3.2763 -  /// and stores it in the \c comp map:
  3.2764 -  ///\code
  3.2765 -  /// typedef Graph::NodeMap<int> ComponentMap;
  3.2766 -  /// ComponentMap comp(graph);
  3.2767 -  /// typedef FillBoolMap<Graph::NodeMap<int> > ComponentFillerMap;
  3.2768 -  /// ComponentFillerMap filler(comp, 0);
  3.2769 -  ///
  3.2770 -  /// Dfs<Graph>::DefProcessedMap<ComponentFillerMap>::Create dfs(graph);
  3.2771 -  /// dfs.processedMap(filler);
  3.2772 -  /// dfs.init();
  3.2773 -  /// for (NodeIt it(graph); it != INVALID; ++it) {
  3.2774 -  ///   if (!dfs.reached(it)) {
  3.2775 -  ///     dfs.addSource(it);
  3.2776 -  ///     dfs.start();
  3.2777 -  ///     ++filler.fillValue();
  3.2778 -  ///   }
  3.2779 -  /// }
  3.2780 -  ///\endcode
  3.2781 -  template <typename Map>
  3.2782 -  class FillBoolMap {
  3.2783 -  public:
  3.2784 -    typedef typename Map::Key Key;
  3.2785 -    typedef bool Value;
  3.2786 -
  3.2787 -    /// Constructor
  3.2788 -    FillBoolMap(Map& _map, const typename Map::Value& _fill) 
  3.2789 -      : map(_map), fill(_fill) {}
  3.2790 -
  3.2791 -    /// Constructor
  3.2792 -    FillBoolMap(Map& _map) 
  3.2793 -      : map(_map), fill() {}
  3.2794 -
  3.2795 -    /// Gives back the current fill value
  3.2796 -    const typename Map::Value& fillValue() const {
  3.2797 -      return fill;
  3.2798 -    } 
  3.2799 -
  3.2800 -    /// Gives back the current fill value
  3.2801 -    typename Map::Value& fillValue() {
  3.2802 -      return fill;
  3.2803 -    } 
  3.2804 -
  3.2805 -    /// Sets the current fill value
  3.2806 -    void fillValue(const typename Map::Value& _fill) {
  3.2807 -      fill = _fill;
  3.2808 -    } 
  3.2809 -
  3.2810 -    /// The \c set function of the map
  3.2811 -    void set(const Key& key, Value value) {
  3.2812 -      if (value) {
  3.2813 -	map.set(key, fill);
  3.2814 -      }
  3.2815 -    }
  3.2816 -    
  3.2817 -  private:
  3.2818 -    Map& map;
  3.2819 -    typename Map::Value fill;
  3.2820 -  };
  3.2821 -
  3.2822 -
  3.2823 -  /// \brief Writable bool map for storing the sequence number of 
  3.2824 -  /// \c true assignments.  
  3.2825 -  /// 
  3.2826 -  /// Writable bool map that stores for each \c true assigned elements  
  3.2827 -  /// the sequence number of this setting.
  3.2828 -  /// It makes it easy to calculate the leaving
  3.2829 -  /// order of the nodes in the \c Dfs algorithm.
  3.2830 -  ///
  3.2831 -  ///\code
  3.2832 -  /// typedef Digraph::NodeMap<int> OrderMap;
  3.2833 -  /// OrderMap order(digraph);
  3.2834 -  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
  3.2835 -  /// OrderSetterMap setter(order);
  3.2836 -  /// Dfs<Digraph>::DefProcessedMap<OrderSetterMap>::Create dfs(digraph);
  3.2837 -  /// dfs.processedMap(setter);
  3.2838 -  /// dfs.init();
  3.2839 -  /// for (NodeIt it(digraph); it != INVALID; ++it) {
  3.2840 -  ///   if (!dfs.reached(it)) {
  3.2841 -  ///     dfs.addSource(it);
  3.2842 -  ///     dfs.start();
  3.2843 -  ///   }
  3.2844 -  /// }
  3.2845 -  ///\endcode
  3.2846 -  ///
  3.2847 -  /// The storing of the discovering order is more difficult because the
  3.2848 -  /// ReachedMap should be readable in the dfs algorithm but the setting
  3.2849 -  /// order map is not readable. Thus we must use the fork map:
  3.2850 -  ///
  3.2851 -  ///\code
  3.2852 -  /// typedef Digraph::NodeMap<int> OrderMap;
  3.2853 -  /// OrderMap order(digraph);
  3.2854 -  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
  3.2855 -  /// OrderSetterMap setter(order);
  3.2856 -  /// typedef Digraph::NodeMap<bool> StoreMap;
  3.2857 -  /// StoreMap store(digraph);
  3.2858 -  ///
  3.2859 -  /// typedef ForkWriteMap<StoreMap, OrderSetterMap> ReachedMap;
  3.2860 -  /// ReachedMap reached(store, setter);
  3.2861 -  ///
  3.2862 -  /// Dfs<Digraph>::DefReachedMap<ReachedMap>::Create dfs(digraph);
  3.2863 -  /// dfs.reachedMap(reached);
  3.2864 -  /// dfs.init();
  3.2865 -  /// for (NodeIt it(digraph); it != INVALID; ++it) {
  3.2866 -  ///   if (!dfs.reached(it)) {
  3.2867 -  ///     dfs.addSource(it);
  3.2868 -  ///     dfs.start();
  3.2869 -  ///   }
  3.2870 -  /// }
  3.2871 -  ///\endcode
  3.2872 -  template <typename Map>
  3.2873 -  class SettingOrderBoolMap {
  3.2874 -  public:
  3.2875 -    typedef typename Map::Key Key;
  3.2876 -    typedef bool Value;
  3.2877 -
  3.2878 -    /// Constructor
  3.2879 -    SettingOrderBoolMap(Map& _map) 
  3.2880 -      : map(_map), counter(0) {}
  3.2881 -
  3.2882 -    /// Number of set operations.
  3.2883 -    int num() const {
  3.2884 -      return counter;
  3.2885 -    }
  3.2886 -
  3.2887 -    /// The \c set function of the map
  3.2888 -    void set(const Key& key, Value value) {
  3.2889 -      if (value) {
  3.2890 -	map.set(key, counter++);
  3.2891 -      }
  3.2892 -    }
  3.2893 -    
  3.2894 -  private:
  3.2895 -    Map& map;
  3.2896 -    int counter;
  3.2897 -  };
  3.2898 +  /// \relates LessMap
  3.2899 +  template<typename M1, typename M2>
  3.2900 +  inline LessMap<M1, M2> lessMap(const M1 &m1, const M2 &m2) {
  3.2901 +    return LessMap<M1, M2>(m1,m2);
  3.2902 +  }
  3.2903  
  3.2904    /// @}
  3.2905  }
     4.1 --- a/test/maps_test.cc	Thu Feb 28 17:06:02 2008 +0100
     4.2 +++ b/test/maps_test.cc	Sun Mar 16 07:32:43 2008 +0000
     4.3 @@ -37,72 +37,256 @@
     4.4    typedef A argument_type;
     4.5    typedef B result_type;
     4.6  
     4.7 -  B operator()(const A &) const {return B();}
     4.8 +  B operator()(const A&) const { return B(); }
     4.9 +private:
    4.10 +  F& operator=(const F&);
    4.11  };
    4.12  
    4.13 -int func(A) {return 3;}
    4.14 +int func(A) { return 3; }
    4.15  
    4.16 -int binc(int, B) {return 4;}
    4.17 +int binc(int a, B) { return a+1; }
    4.18  
    4.19 -typedef ReadMap<A,double> DoubleMap;
    4.20 -typedef ReadWriteMap<A, double> WriteDoubleMap;
    4.21 +typedef ReadMap<A, double> DoubleMap;
    4.22 +typedef ReadWriteMap<A, double> DoubleWriteMap;
    4.23 +typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap;
    4.24  
    4.25 -typedef ReadMap<A,bool> BoolMap;
    4.26 +typedef ReadMap<A, bool> BoolMap;
    4.27  typedef ReadWriteMap<A, bool> BoolWriteMap;
    4.28 +typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap;
    4.29  
    4.30  int main()
    4.31 -{ // checking graph components
    4.32 -  
    4.33 +{
    4.34 +  // Map concepts
    4.35    checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
    4.36    checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
    4.37    checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
    4.38    checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
    4.39  
    4.40 -  checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
    4.41 -  checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
    4.42 -  checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
    4.43 -  checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
    4.44 -  checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
    4.45 -  checkConcept<ReadWriteMap<A,double>, NegWriteMap<WriteDoubleMap> >();
    4.46 -  checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
    4.47 -  checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
    4.48 -  checkConcept<ReadWriteMap<A,double>, ShiftWriteMap<WriteDoubleMap> >();
    4.49 -  checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
    4.50 -  checkConcept<ReadWriteMap<A,double>, ScaleWriteMap<WriteDoubleMap> >();
    4.51 -  checkConcept<ReadMap<A,double>, ForkMap<DoubleMap, DoubleMap> >();
    4.52 -  checkConcept<ReadWriteMap<A,double>, 
    4.53 -    ForkWriteMap<WriteDoubleMap, WriteDoubleMap> >();
    4.54 -  
    4.55 -  checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
    4.56 +  // NullMap
    4.57 +  {
    4.58 +    checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
    4.59 +    NullMap<A,B> map1;
    4.60 +    NullMap<A,B> map2 = map1;
    4.61 +    map1 = nullMap<A,B>();
    4.62 +  }
    4.63  
    4.64 -  checkConcept<ReadMap<A,B>, FunctorMap<F, A, B> >();
    4.65 +  // ConstMap
    4.66 +  {
    4.67 +    checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >();
    4.68 +    ConstMap<A,B> map1;
    4.69 +    ConstMap<A,B> map2(B());
    4.70 +    ConstMap<A,B> map3 = map1;
    4.71 +    map1 = constMap<A>(B());
    4.72 +    map1.setAll(B());
    4.73  
    4.74 -  checkConcept<ReadMap<A, bool>, NotMap<BoolMap> >();
    4.75 -  checkConcept<ReadWriteMap<A, bool>, NotWriteMap<BoolWriteMap> >();
    4.76 +    checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
    4.77 +    check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
    4.78  
    4.79 -  checkConcept<WriteMap<A, bool>, StoreBoolMap<A*> >();
    4.80 -  checkConcept<WriteMap<A, bool>, BackInserterBoolMap<std::deque<A> > >();
    4.81 -  checkConcept<WriteMap<A, bool>, FrontInserterBoolMap<std::deque<A> > >();
    4.82 -  checkConcept<WriteMap<A, bool>, InserterBoolMap<std::set<A> > >();
    4.83 -  checkConcept<WriteMap<A, bool>, FillBoolMap<WriteMap<A, B> > >();
    4.84 -  checkConcept<WriteMap<A, bool>, SettingOrderBoolMap<WriteMap<A, int> > >();
    4.85 +    checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >();
    4.86 +    ConstMap<A,Const<int,10> > map4;
    4.87 +    ConstMap<A,Const<int,10> > map5 = map4;
    4.88 +    map4 = map5;
    4.89 +    check(map4[A()] == 10 && map5[A()] == 10, "Something is wrong with ConstMap");
    4.90 +  }
    4.91  
    4.92 -  int a;
    4.93 -  
    4.94 -  a=mapFunctor(constMap<A,int>(2))(A());
    4.95 -  check(a==2,"Something is wrong with mapFunctor");
    4.96 +  // IdentityMap
    4.97 +  {
    4.98 +    checkConcept<ReadMap<A,A>, IdentityMap<A> >();
    4.99 +    IdentityMap<A> map1;
   4.100 +    IdentityMap<A> map2 = map1;
   4.101 +    map1 = identityMap<A>();
   4.102  
   4.103 -  B b;
   4.104 -  b=functorMap(F())[A()];
   4.105 +    checkConcept<ReadMap<double,double>, IdentityMap<double> >();
   4.106 +    check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14,
   4.107 +          "Something is wrong with IdentityMap");
   4.108 +  }
   4.109  
   4.110 -  a=functorMap(&func)[A()];
   4.111 -  check(a==3,"Something is wrong with functorMap");
   4.112 +  // RangeMap
   4.113 +  {
   4.114 +    checkConcept<ReferenceMap<int,B,B&,const B&>, RangeMap<B> >();
   4.115 +    RangeMap<B> map1;
   4.116 +    RangeMap<B> map2(10);
   4.117 +    RangeMap<B> map3(10,B());
   4.118 +    RangeMap<B> map4 = map1;
   4.119 +    RangeMap<B> map5 = rangeMap<B>();
   4.120 +    RangeMap<B> map6 = rangeMap<B>(10);
   4.121 +    RangeMap<B> map7 = rangeMap(10,B());
   4.122  
   4.123 -  a=combineMap(constMap<B, int, 1>(), identityMap<B>(), &binc)[B()];
   4.124 -  check(a==4,"Something is wrong with combineMap");
   4.125 -  
   4.126 +    checkConcept< ReferenceMap<int, double, double&, const double&>,
   4.127 +                  RangeMap<double> >();
   4.128 +    std::vector<double> v(10, 0);
   4.129 +    v[5] = 100;
   4.130 +    RangeMap<double> map8(v);
   4.131 +    RangeMap<double> map9 = rangeMap(v);
   4.132 +    check(map9.size() == 10 && map9[2] == 0 && map9[5] == 100,
   4.133 +          "Something is wrong with RangeMap");
   4.134 +  }
   4.135  
   4.136 -  std::cout << __FILE__ ": All tests passed.\n";
   4.137 -  
   4.138 +  // SparseMap
   4.139 +  {
   4.140 +    checkConcept<ReferenceMap<A,B,B&,const B&>, SparseMap<A,B> >();
   4.141 +    SparseMap<A,B> map1;
   4.142 +    SparseMap<A,B> map2(B());
   4.143 +    SparseMap<A,B> map3 = sparseMap<A,B>();
   4.144 +    SparseMap<A,B> map4 = sparseMap<A>(B());
   4.145 +
   4.146 +    checkConcept< ReferenceMap<double, int, int&, const int&>,
   4.147 +                  SparseMap<double, int> >();
   4.148 +    std::map<double, int> m;
   4.149 +    SparseMap<double, int> map5(m);
   4.150 +    SparseMap<double, int> map6(m,10);
   4.151 +    SparseMap<double, int> map7 = sparseMap(m);
   4.152 +    SparseMap<double, int> map8 = sparseMap(m,10);
   4.153 +
   4.154 +    check(map5[1.0] == 0 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 10,
   4.155 +          "Something is wrong with SparseMap");
   4.156 +    map5[1.0] = map6[3.14] = 100;
   4.157 +    check(map5[1.0] == 100 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 100,
   4.158 +          "Something is wrong with SparseMap");
   4.159 +  }
   4.160 +
   4.161 +  // ComposeMap
   4.162 +  {
   4.163 +    typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
   4.164 +    checkConcept<ReadMap<B,double>, CompMap>();
   4.165 +    CompMap map1(DoubleMap(),ReadMap<B,A>());
   4.166 +    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
   4.167 +
   4.168 +    SparseMap<double, bool> m1(false); m1[3.14] = true;
   4.169 +    RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
   4.170 +    check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], "Something is wrong with ComposeMap")
   4.171 +  }
   4.172 +
   4.173 +  // CombineMap
   4.174 +  {
   4.175 +    typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
   4.176 +    checkConcept<ReadMap<A,double>, CombMap>();
   4.177 +    CombMap map1(DoubleMap(), DoubleMap());
   4.178 +    CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
   4.179 +
   4.180 +    check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
   4.181 +          "Something is wrong with CombineMap");
   4.182 +  }
   4.183 +
   4.184 +  // FunctorToMap, MapToFunctor
   4.185 +  {
   4.186 +    checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
   4.187 +    checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
   4.188 +    FunctorToMap<F> map1;
   4.189 +    FunctorToMap<F> map2(F());
   4.190 +    B b = functorToMap(F())[A()];
   4.191 +
   4.192 +    checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
   4.193 +    MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>());
   4.194 +
   4.195 +    check(functorToMap(&func)[A()] == 3, "Something is wrong with FunctorToMap");
   4.196 +    check(mapToFunctor(constMap<A,int>(2))(A()) == 2, "Something is wrong with MapToFunctor");
   4.197 +    check(mapToFunctor(functorToMap(&func))(A()) == 3 && mapToFunctor(functorToMap(&func))[A()] == 3,
   4.198 +          "Something is wrong with FunctorToMap or MapToFunctor");
   4.199 +    check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2,
   4.200 +          "Something is wrong with FunctorToMap or MapToFunctor");
   4.201 +  }
   4.202 +
   4.203 +  // ConvertMap
   4.204 +  {
   4.205 +    checkConcept<ReadMap<double,double>, ConvertMap<ReadMap<double, int>, double> >();
   4.206 +    ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true));
   4.207 +    ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false));
   4.208 +  }
   4.209 +
   4.210 +  // ForkMap
   4.211 +  {
   4.212 +    checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
   4.213 +
   4.214 +    typedef RangeMap<double> RM;
   4.215 +    typedef SparseMap<int, double> SM;
   4.216 +    RM m1(10, -1);
   4.217 +    SM m2(-1);
   4.218 +    checkConcept<ReadWriteMap<int, double>, ForkMap<RM, SM> >();
   4.219 +    checkConcept<ReadWriteMap<int, double>, ForkMap<SM, RM> >();
   4.220 +    ForkMap<RM, SM> map1(m1,m2);
   4.221 +    ForkMap<SM, RM> map2 = forkMap(m2,m1);
   4.222 +    map2.set(5, 10);
   4.223 +    check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && m2[5] == 10 && map2[1] == -1 && map2[5] == 10,
   4.224 +          "Something is wrong with ForkMap");
   4.225 +  }
   4.226 +
   4.227 +  // Arithmetic maps:
   4.228 +  // - AddMap, SubMap, MulMap, DivMap
   4.229 +  // - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap
   4.230 +  // - NegMap, NegWriteMap, AbsMap
   4.231 +  {
   4.232 +    checkConcept<DoubleMap, AddMap<DoubleMap,DoubleMap> >();
   4.233 +    checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >();
   4.234 +    checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
   4.235 +    checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
   4.236 +
   4.237 +    ConstMap<int, double> c1(1.0), c2(3.14);
   4.238 +    IdentityMap<int> im;
   4.239 +    ConvertMap<IdentityMap<int>, double> id(im);
   4.240 +    check(addMap(c1,id)[0] == 1.0  && addMap(c1,id)[10] == 11.0, "Something is wrong with AddMap");
   4.241 +    check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0,  "Something is wrong with SubMap");
   4.242 +    check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28, "Something is wrong with MulMap");
   4.243 +    check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57, "Something is wrong with DivMap");
   4.244 +
   4.245 +    checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
   4.246 +    checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
   4.247 +    checkConcept<DoubleMap, ScaleMap<DoubleMap> >();
   4.248 +    checkConcept<DoubleWriteMap, ScaleWriteMap<DoubleWriteMap> >();
   4.249 +    checkConcept<DoubleMap, NegMap<DoubleMap> >();
   4.250 +    checkConcept<DoubleWriteMap, NegWriteMap<DoubleWriteMap> >();
   4.251 +    checkConcept<DoubleMap, AbsMap<DoubleMap> >();
   4.252 +
   4.253 +    check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0,
   4.254 +          "Something is wrong with ShiftMap");
   4.255 +    check(shiftWriteMap(id, 2.0)[1] == 3.0 && shiftWriteMap(id, 2.0)[10] == 12.0,
   4.256 +          "Something is wrong with ShiftWriteMap");
   4.257 +    check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0,
   4.258 +          "Something is wrong with ScaleMap");
   4.259 +    check(scaleWriteMap(id, 2.0)[1] == 2.0 && scaleWriteMap(id, 2.0)[10] == 20.0,
   4.260 +          "Something is wrong with ScaleWriteMap");
   4.261 +    check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0,
   4.262 +          "Something is wrong with NegMap");
   4.263 +    check(negWriteMap(id)[1] == -1.0 && negWriteMap(id)[-10] == 10.0,
   4.264 +          "Something is wrong with NegWriteMap");
   4.265 +    check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0,
   4.266 +          "Something is wrong with AbsMap");
   4.267 +  }
   4.268 +
   4.269 +  // Logical maps:
   4.270 +  // - TrueMap, FalseMap
   4.271 +  // - AndMap, OrMap
   4.272 +  // - NotMap, NotWriteMap
   4.273 +  // - EqualMap, LessMap
   4.274 +  {
   4.275 +    checkConcept<BoolMap, TrueMap<A> >();
   4.276 +    checkConcept<BoolMap, FalseMap<A> >();
   4.277 +    checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >();
   4.278 +    checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >();
   4.279 +    checkConcept<BoolMap, NotMap<BoolMap> >();
   4.280 +    checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
   4.281 +    checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >();
   4.282 +    checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >();
   4.283 +
   4.284 +    TrueMap<int> tm;
   4.285 +    FalseMap<int> fm;
   4.286 +    RangeMap<bool> rm(2);
   4.287 +    rm[0] = true; rm[1] = false;
   4.288 +    check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && !andMap(fm,rm)[0] && !andMap(fm,rm)[1],
   4.289 +          "Something is wrong with AndMap");
   4.290 +    check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && orMap(fm,rm)[0] && !orMap(fm,rm)[1],
   4.291 +          "Something is wrong with OrMap");
   4.292 +    check(!notMap(rm)[0] && notMap(rm)[1], "Something is wrong with NotMap");
   4.293 +    check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
   4.294 +
   4.295 +    ConstMap<int, double> cm(2.0);
   4.296 +    IdentityMap<int> im;
   4.297 +    ConvertMap<IdentityMap<int>, double> id(im);
   4.298 +    check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3],
   4.299 +          "Something is wrong with LessMap");
   4.300 +    check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
   4.301 +          "Something is wrong with EqualMap");
   4.302 +  }
   4.303 +
   4.304    return 0;
   4.305  }