Bug fix and redesign StdMap
authordeba
Tue, 09 Oct 2007 15:46:12 +0000
changeset 248948dddc283cfc
parent 2488 da94e3b332f3
child 2490 31a93dd6f714
Bug fix and redesign StdMap
Improving map adaptors documentations
doc/groups.dox
lemon/maps.h
     1.1 --- a/doc/groups.dox	Tue Oct 09 09:36:54 2007 +0000
     1.2 +++ b/doc/groups.dox	Tue Oct 09 15:46:12 2007 +0000
     1.3 @@ -97,6 +97,57 @@
     1.4  make arithmetic operations between one or two maps (negation, scaling,
     1.5  addition, multiplication etc.) or e.g. convert a map to another one
     1.6  of different Value type.
     1.7 +
     1.8 +The typical usage of this classes is the passing implicit maps to
     1.9 +algorithms.  If a function type algorithm is called then the function
    1.10 +type map adaptors can be used comfortable. For example let's see the
    1.11 +usage of map adaptors with the \c graphToEps() function:
    1.12 +\code
    1.13 +  Color nodeColor(int deg) {
    1.14 +    if (deg >= 2) {
    1.15 +      return Color(0.5, 0.0, 0.5);
    1.16 +    } else if (deg == 1) {
    1.17 +      return Color(1.0, 0.5, 1.0);
    1.18 +    } else {
    1.19 +      return Color(0.0, 0.0, 0.0);
    1.20 +    }
    1.21 +  }
    1.22 +  
    1.23 +  Graph::NodeMap<int> degree_map(graph);
    1.24 +  
    1.25 +  graphToEps(graph, "graph.eps")
    1.26 +    .coords(coords).scaleToA4().undirected()
    1.27 +    .nodeColors(composeMap(functorMap(nodeColor), degree_map)) 
    1.28 +    .run();
    1.29 +\endcode 
    1.30 +The \c functorMap() function makes an \c int to \c Color map from the
    1.31 +\e nodeColor() function. The \c composeMap() compose the \e degree_map
    1.32 +and the previous created map. The composed map is proper function to
    1.33 +get color of each node.
    1.34 +
    1.35 +The usage with class type algorithms is little bit harder. In this
    1.36 +case the function type map adaptors can not be used, because the
    1.37 +function map adaptors give back temporarly objects.
    1.38 +\code
    1.39 +  Graph graph;
    1.40 +  
    1.41 +  typedef Graph::EdgeMap<double> DoubleEdgeMap;
    1.42 +  DoubleEdgeMap length(graph);
    1.43 +  DoubleEdgeMap speed(graph);
    1.44 +  
    1.45 +  typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap;
    1.46 +  
    1.47 +  TimeMap time(length, speed);
    1.48 +  
    1.49 +  Dijkstra<Graph, TimeMap> dijkstra(graph, time);
    1.50 +  dijkstra.run(source, target);
    1.51 +\endcode
    1.52 +
    1.53 +We have a length map and a maximum speed map on a graph. The minimum
    1.54 +time to pass the edge can be calculated as the division of the two
    1.55 +maps which can be done implicitly with the \c DivMap template
    1.56 +class. We use the implicit minimum time map as the length map of the
    1.57 +\c Dijkstra algorithm.
    1.58  */
    1.59  
    1.60  /**
    1.61 @@ -115,9 +166,10 @@
    1.62  LEMON provides flexible data structures
    1.63  to work with paths.
    1.64  
    1.65 -All of them have the same interface, especially they can be built or extended
    1.66 -using a standard Builder subclass. This make is easy to have e.g. the Dijkstra
    1.67 -algorithm to store its result in any kind of path structure.
    1.68 +All of them have similar interfaces, and it can be copied easily with
    1.69 +assignment operator and copy constructor. This make it easy and
    1.70 +efficient to have e.g. the Dijkstra algorithm to store its result in
    1.71 +any kind of path structure.
    1.72  
    1.73  \sa lemon::concepts::Path
    1.74  
     2.1 --- a/lemon/maps.h	Tue Oct 09 09:36:54 2007 +0000
     2.2 +++ b/lemon/maps.h	Tue Oct 09 15:46:12 2007 +0000
     2.3 @@ -29,9 +29,6 @@
     2.4  ///\ingroup maps
     2.5  ///\brief Miscellaneous property maps
     2.6  ///
     2.7 -///\todo This file has the same name as the concept file in concepts/,
     2.8 -/// and this is not easily detectable in docs...
     2.9 -
    2.10  #include <map>
    2.11  
    2.12  namespace lemon {
    2.13 @@ -79,8 +76,7 @@
    2.14    /// Constant map.
    2.15  
    2.16    /// This is a readable map which assigns a specified value to each key.
    2.17 -  /// In other aspects it is equivalent to the \ref NullMap.
    2.18 -  /// \todo set could be used to set the value.
    2.19 +  /// In other aspects it is equivalent to the \c NullMap.
    2.20    template<typename K, typename T>
    2.21    class ConstMap : public MapBase<K, T> {
    2.22    private:
    2.23 @@ -101,9 +97,14 @@
    2.24      /// \param _v The initial value of the map.
    2.25      ///
    2.26      ConstMap(const T &_v) : v(_v) {}
    2.27 +    
    2.28 +    ///\e
    2.29 +    T operator[](const K&) const { return v; }
    2.30  
    2.31 -    T operator[](const K&) const { return v; }
    2.32 -    void set(const K&, const T&) {}
    2.33 +    ///\e
    2.34 +    void setAll(const T &t) {
    2.35 +      v = t;
    2.36 +    }    
    2.37  
    2.38      template<typename T1>
    2.39      struct rebind {
    2.40 @@ -114,9 +115,9 @@
    2.41      ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
    2.42    };
    2.43  
    2.44 -  ///Returns a \ref ConstMap class
    2.45 +  ///Returns a \c ConstMap class
    2.46  
    2.47 -  ///This function just returns a \ref ConstMap class.
    2.48 +  ///This function just returns a \c ConstMap class.
    2.49    ///\relates ConstMap
    2.50    template<typename K, typename V> 
    2.51    inline ConstMap<K, V> constMap(const V &v) {
    2.52 @@ -124,11 +125,13 @@
    2.53    }
    2.54  
    2.55  
    2.56 -  //\todo to document later
    2.57    template<typename T, T v>
    2.58    struct Const { };
    2.59  
    2.60 -  //\todo to document later
    2.61 +  /// Constant map with inlined constant value.
    2.62 +
    2.63 +  /// This is a readable map which assigns a specified value to each key.
    2.64 +  /// In other aspects it is equivalent to the \c NullMap.
    2.65    template<typename K, typename V, V v>
    2.66    class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
    2.67    public:
    2.68 @@ -137,32 +140,32 @@
    2.69      typedef typename Parent::Value Value;
    2.70  
    2.71      ConstMap() { }
    2.72 +    ///\e
    2.73      V operator[](const K&) const { return v; }
    2.74 +    ///\e
    2.75      void set(const K&, const V&) { }
    2.76    };
    2.77  
    2.78 -  ///Returns a \ref ConstMap class
    2.79 +  ///Returns a \c ConstMap class
    2.80  
    2.81 -  ///This function just returns a \ref ConstMap class.
    2.82 +  ///This function just returns a \c ConstMap class with inlined value.
    2.83    ///\relates ConstMap
    2.84    template<typename K, typename V, V v> 
    2.85    inline ConstMap<K, Const<V, v> > constMap() {
    2.86      return ConstMap<K, Const<V, v> >();
    2.87    }
    2.88  
    2.89 -  /// \c std::map wrapper
    2.90 +  ///Map based on std::map
    2.91  
    2.92 -  /// This is essentially a wrapper for \c std::map. With addition that
    2.93 -  /// you can specify a default value different from \c Value() .
    2.94 -  ///
    2.95 -  /// \todo Provide allocator parameter...
    2.96 +  ///This is essentially a wrapper for \c std::map. With addition that
    2.97 +  ///you can specify a default value different from \c Value() .
    2.98    template <typename K, typename T, typename Compare = std::less<K> >
    2.99 -  class StdMap : public std::map<K, T, Compare> {
   2.100 -    typedef std::map<K, T, Compare> parent;
   2.101 -    T v;
   2.102 -    typedef typename parent::value_type PairType;
   2.103 +  class StdMap {
   2.104 +    template <typename K1, typename T1, typename C1>
   2.105 +    friend class StdMap;
   2.106 +  public:
   2.107  
   2.108 -  public:
   2.109 +    typedef True ReferenceMapTag;
   2.110      ///\e
   2.111      typedef K Key;
   2.112      ///\e
   2.113 @@ -172,50 +175,69 @@
   2.114      ///\e
   2.115      typedef const T& ConstReference;
   2.116  
   2.117 +  private:
   2.118 +    
   2.119 +    typedef std::map<K, T, Compare> Map;
   2.120 +    Value _value;
   2.121 +    Map _map;
   2.122  
   2.123 -    StdMap() : v() {}
   2.124 +  public:
   2.125 +
   2.126      /// Constructor with specified default value
   2.127 -    StdMap(const T& _v) : v(_v) {}
   2.128 -
   2.129 -    /// \brief Constructs the map from an appropriate std::map.
   2.130 -    ///
   2.131 -    /// \warning Inefficient: copies the content of \c m !
   2.132 -    StdMap(const parent &m) : parent(m) {}
   2.133 +    StdMap(const T& value = T()) : _value(value) {}
   2.134      /// \brief Constructs the map from an appropriate std::map, and explicitly
   2.135      /// specifies a default value.
   2.136 -    ///
   2.137 -    /// \warning Inefficient: copies the content of \c m !
   2.138 -    StdMap(const parent &m, const T& _v) : parent(m), v(_v) {}
   2.139 +    template <typename T1, typename Comp1>
   2.140 +    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
   2.141 +      : _map(map.begin(), map.end()), _value(value) {}
   2.142      
   2.143 +    /// \brief Constructs a map from an other StdMap.
   2.144      template<typename T1, typename Comp1>
   2.145 -    StdMap(const StdMap<Key, T1,Comp1> &m, const T &_v) { 
   2.146 -      //FIXME; 
   2.147 +    StdMap(const StdMap<Key, T1, Comp1> &c) 
   2.148 +      : _map(c._map.begin(), c._map.end()), _value(c._value) {}
   2.149 +
   2.150 +  private:
   2.151 +
   2.152 +    StdMap& operator=(const StdMap&);
   2.153 +
   2.154 +  public:
   2.155 +
   2.156 +    ///\e
   2.157 +    Reference operator[](const Key &k) {
   2.158 +      typename Map::iterator it = _map.lower_bound(k);
   2.159 +      if (it != _map.end() && !_map.key_comp()(k, it->first))
   2.160 +	return it->second;
   2.161 +      else
   2.162 +	return _map.insert(it, std::make_pair(k, _value))->second;
   2.163      }
   2.164  
   2.165 -    Reference operator[](const Key &k) {
   2.166 -      return insert(PairType(k,v)).first -> second;
   2.167 +    /// \e 
   2.168 +    ConstReference operator[](const Key &k) const {
   2.169 +      typename Map::const_iterator it = _map.find(k);
   2.170 +      if (it != _map.end())
   2.171 +	return it->second;
   2.172 +      else
   2.173 +	return _value;
   2.174      }
   2.175  
   2.176 -    ConstReference operator[](const Key &k) const {
   2.177 -      typename parent::iterator i = lower_bound(k);
   2.178 -      if (i == parent::end() || parent::key_comp()(k, (*i).first))
   2.179 -	return v;
   2.180 -      return (*i).second;
   2.181 -    }
   2.182 +    /// \e 
   2.183      void set(const Key &k, const T &t) {
   2.184 -      parent::operator[](k) = t;
   2.185 +      typename Map::iterator it = _map.lower_bound(k);
   2.186 +      if (it != _map.end() && !_map.key_comp()(k, it->first))
   2.187 +	it->second = t;
   2.188 +      else
   2.189 +	_map.insert(it, std::make_pair(k, t));
   2.190      }
   2.191  
   2.192 -    /// Changes the default value of the map.
   2.193 -    /// \return Returns the previous default value.
   2.194 -    ///
   2.195 -    /// \warning The value of some keys (which has already been queried, but
   2.196 -    /// the value has been unchanged from the default) may change!
   2.197 -    T setDefault(const T &_v) { T old=v; v=_v; return old; }
   2.198 +    /// \e
   2.199 +    void setAll(const T &t) {
   2.200 +      _value = t;
   2.201 +      _map.clear();
   2.202 +    }    
   2.203  
   2.204 -    template<typename T1>
   2.205 +    template <typename T1, typename C1 = std::less<T1> >
   2.206      struct rebind {
   2.207 -      typedef StdMap<Key, T1,Compare> other;
   2.208 +      typedef StdMap<Key, T1, C1> other;
   2.209      };
   2.210    };
   2.211  
   2.212 @@ -235,14 +257,15 @@
   2.213      typedef typename Parent::Key Key;
   2.214      typedef typename Parent::Value Value;
   2.215  
   2.216 +    /// \e
   2.217      const T& operator[](const T& t) const {
   2.218        return t;
   2.219      }
   2.220    };
   2.221  
   2.222 -  ///Returns an \ref IdentityMap class
   2.223 +  ///Returns an \c IdentityMap class
   2.224  
   2.225 -  ///This function just returns an \ref IdentityMap class.
   2.226 +  ///This function just returns an \c IdentityMap class.
   2.227    ///\relates IdentityMap
   2.228    template<typename T>
   2.229    inline IdentityMap<T> identityMap() {
   2.230 @@ -252,7 +275,7 @@
   2.231  
   2.232    ///Convert the \c Value of a map to another type.
   2.233  
   2.234 -  ///This \ref concepts::ReadMap "read only map"
   2.235 +  ///This \c concepts::ReadMap "read only map"
   2.236    ///converts the \c Value of a maps to type \c T.
   2.237    ///Its \c Key is inherited from \c M.
   2.238    template <typename M, typename T> 
   2.239 @@ -277,11 +300,10 @@
   2.240      Value operator[](const Key& k) const {return m[k];}
   2.241    };
   2.242    
   2.243 -  ///Returns an \ref ConvertMap class
   2.244 +  ///Returns an \c ConvertMap class
   2.245  
   2.246 -  ///This function just returns an \ref ConvertMap class.
   2.247 +  ///This function just returns an \c ConvertMap class.
   2.248    ///\relates ConvertMap
   2.249 -  ///\todo The order of the template parameters are changed.
   2.250    template<typename T, typename M>
   2.251    inline ConvertMap<M, T> convertMap(const M &m) {
   2.252      return ConvertMap<M, T>(m);
   2.253 @@ -289,7 +311,7 @@
   2.254  
   2.255    ///Simple wrapping of the map
   2.256  
   2.257 -  ///This \ref concepts::ReadMap "read only map" returns the simple
   2.258 +  ///This \c concepts::ReadMap "read only map" returns the simple
   2.259    ///wrapping of the given map. Sometimes the reference maps cannot be
   2.260    ///combined with simple read maps. This map adaptor wraps the given
   2.261    ///map to simple read map.
   2.262 @@ -304,12 +326,13 @@
   2.263  
   2.264      ///Constructor
   2.265      SimpleMap(const M &_m) : m(_m) {};
   2.266 +    ///\e
   2.267      Value operator[](Key k) const {return m[k];}
   2.268    };
   2.269  
   2.270    ///Simple writeable wrapping of the map
   2.271  
   2.272 -  ///This \ref concepts::ReadMap "read only map" returns the simple
   2.273 +  ///This \c concepts::ReadMap "read only map" returns the simple
   2.274    ///wrapping of the given map. Sometimes the reference maps cannot be
   2.275    ///combined with simple read-write maps. This map adaptor wraps the
   2.276    ///given map to simple read-write map.
   2.277 @@ -324,13 +347,15 @@
   2.278  
   2.279      ///Constructor
   2.280      SimpleWriteMap(M &_m) : m(_m) {};
   2.281 +    ///\e
   2.282      Value operator[](Key k) const {return m[k];}
   2.283 +    ///\e
   2.284      void set(Key k, const Value& c) { m.set(k, c); }
   2.285    };
   2.286  
   2.287    ///Sum of two maps
   2.288  
   2.289 -  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
   2.290 +  ///This \c concepts::ReadMap "read only map" returns the sum of the two
   2.291    ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   2.292    ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
   2.293  
   2.294 @@ -346,16 +371,16 @@
   2.295  
   2.296      ///Constructor
   2.297      AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   2.298 +    ///\e
   2.299      Value operator[](Key k) const {return m1[k]+m2[k];}
   2.300    };
   2.301    
   2.302 -  ///Returns an \ref AddMap class
   2.303 +  ///Returns an \c AddMap class
   2.304  
   2.305 -  ///This function just returns an \ref AddMap class.
   2.306 +  ///This function just returns an \c AddMap class.
   2.307    ///\todo How to call these type of functions?
   2.308    ///
   2.309    ///\relates AddMap
   2.310 -  ///\todo Wrong scope in Doxygen when \c \\relates is used
   2.311    template<typename M1, typename M2> 
   2.312    inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
   2.313      return AddMap<M1, M2>(m1,m2);
   2.314 @@ -363,7 +388,7 @@
   2.315  
   2.316    ///Shift a map with a constant.
   2.317  
   2.318 -  ///This \ref concepts::ReadMap "read only map" returns the sum of the
   2.319 +  ///This \c concepts::ReadMap "read only map" returns the sum of the
   2.320    ///given map and a constant value.
   2.321    ///Its \c Key and \c Value is inherited from \c M.
   2.322    ///
   2.323 @@ -391,12 +416,13 @@
   2.324      ///\param _m is the undelying map
   2.325      ///\param _v is the shift value
   2.326      ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
   2.327 +    ///\e
   2.328      Value operator[](Key k) const {return m[k] + v;}
   2.329    };
   2.330  
   2.331    ///Shift a map with a constant.
   2.332  
   2.333 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
   2.334 +  ///This \c concepts::ReadWriteMap "read-write map" returns the sum of the
   2.335    ///given map and a constant value. It makes also possible to write the map.
   2.336    ///Its \c Key and \c Value is inherited from \c M.
   2.337    ///
   2.338 @@ -424,15 +450,16 @@
   2.339      ///\param _m is the undelying map
   2.340      ///\param _v is the shift value
   2.341      ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
   2.342 +    /// \e
   2.343      Value operator[](Key k) const {return m[k] + v;}
   2.344 +    /// \e
   2.345      void set(Key k, const Value& c) { m.set(k, c - v); }
   2.346    };
   2.347    
   2.348 -  ///Returns an \ref ShiftMap class
   2.349 +  ///Returns an \c ShiftMap class
   2.350  
   2.351 -  ///This function just returns an \ref ShiftMap class.
   2.352 +  ///This function just returns an \c ShiftMap class.
   2.353    ///\relates ShiftMap
   2.354 -  ///\todo A better name is required.
   2.355    template<typename M, typename C> 
   2.356    inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
   2.357      return ShiftMap<M, C>(m,v);
   2.358 @@ -445,7 +472,7 @@
   2.359  
   2.360    ///Difference of two maps
   2.361  
   2.362 -  ///This \ref concepts::ReadMap "read only map" returns the difference
   2.363 +  ///This \c concepts::ReadMap "read only map" returns the difference
   2.364    ///of the values of the two
   2.365    ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   2.366    ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   2.367 @@ -461,12 +488,13 @@
   2.368  
   2.369      ///Constructor
   2.370      SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   2.371 +    /// \e
   2.372      Value operator[](Key k) const {return m1[k]-m2[k];}
   2.373    };
   2.374    
   2.375 -  ///Returns a \ref SubMap class
   2.376 +  ///Returns a \c SubMap class
   2.377  
   2.378 -  ///This function just returns a \ref SubMap class.
   2.379 +  ///This function just returns a \c SubMap class.
   2.380    ///
   2.381    ///\relates SubMap
   2.382    template<typename M1, typename M2> 
   2.383 @@ -476,7 +504,7 @@
   2.384  
   2.385    ///Product of two maps
   2.386  
   2.387 -  ///This \ref concepts::ReadMap "read only map" returns the product of the
   2.388 +  ///This \c concepts::ReadMap "read only map" returns the product of the
   2.389    ///values of the two
   2.390    ///given
   2.391    ///maps. Its \c Key and \c Value will be inherited from \c M1.
   2.392 @@ -493,12 +521,13 @@
   2.393  
   2.394      ///Constructor
   2.395      MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   2.396 +    /// \e
   2.397      Value operator[](Key k) const {return m1[k]*m2[k];}
   2.398    };
   2.399    
   2.400 -  ///Returns a \ref MulMap class
   2.401 +  ///Returns a \c MulMap class
   2.402  
   2.403 -  ///This function just returns a \ref MulMap class.
   2.404 +  ///This function just returns a \c MulMap class.
   2.405    ///\relates MulMap
   2.406    template<typename M1, typename M2> 
   2.407    inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
   2.408 @@ -507,7 +536,7 @@
   2.409   
   2.410    ///Scales a maps with a constant.
   2.411  
   2.412 -  ///This \ref concepts::ReadMap "read only map" returns the value of the
   2.413 +  ///This \c concepts::ReadMap "read only map" returns the value of the
   2.414    ///given map multiplied from the left side with a constant value.
   2.415    ///Its \c Key and \c Value is inherited from \c M.
   2.416    ///
   2.417 @@ -535,12 +564,13 @@
   2.418      ///\param _m is the undelying map
   2.419      ///\param _v is the scaling value
   2.420      ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
   2.421 +    /// \e
   2.422      Value operator[](Key k) const {return v * m[k];}
   2.423    };
   2.424  
   2.425    ///Scales a maps with a constant.
   2.426  
   2.427 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
   2.428 +  ///This \c concepts::ReadWriteMap "read-write map" returns the value of the
   2.429    ///given map multiplied from the left side with a constant value. It can
   2.430    ///be used as write map also if the given multiplier is not zero.
   2.431    ///Its \c Key and \c Value is inherited from \c M.
   2.432 @@ -559,15 +589,16 @@
   2.433      ///\param _m is the undelying map
   2.434      ///\param _v is the scaling value
   2.435      ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
   2.436 +    /// \e
   2.437      Value operator[](Key k) const {return v * m[k];}
   2.438 +    /// \e
   2.439      void set(Key k, const Value& c) { m.set(k, c / v);}
   2.440    };
   2.441    
   2.442 -  ///Returns an \ref ScaleMap class
   2.443 +  ///Returns an \c ScaleMap class
   2.444  
   2.445 -  ///This function just returns an \ref ScaleMap class.
   2.446 +  ///This function just returns an \c ScaleMap class.
   2.447    ///\relates ScaleMap
   2.448 -  ///\todo A better name is required.
   2.449    template<typename M, typename C> 
   2.450    inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
   2.451      return ScaleMap<M, C>(m,v);
   2.452 @@ -580,7 +611,7 @@
   2.453  
   2.454    ///Quotient of two maps
   2.455  
   2.456 -  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
   2.457 +  ///This \c concepts::ReadMap "read only map" returns the quotient of the
   2.458    ///values of the two
   2.459    ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   2.460    ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
   2.461 @@ -596,12 +627,13 @@
   2.462  
   2.463      ///Constructor
   2.464      DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   2.465 +    /// \e
   2.466      Value operator[](Key k) const {return m1[k]/m2[k];}
   2.467    };
   2.468    
   2.469 -  ///Returns a \ref DivMap class
   2.470 +  ///Returns a \c DivMap class
   2.471  
   2.472 -  ///This function just returns a \ref DivMap class.
   2.473 +  ///This function just returns a \c DivMap class.
   2.474    ///\relates DivMap
   2.475    template<typename M1, typename M2> 
   2.476    inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
   2.477 @@ -610,7 +642,7 @@
   2.478    
   2.479    ///Composition of two maps
   2.480  
   2.481 -  ///This \ref concepts::ReadMap "read only map" returns the composition of
   2.482 +  ///This \c concepts::ReadMap "read only map" returns the composition of
   2.483    ///two
   2.484    ///given maps. That is to say, if \c m1 is of type \c M1 and \c m2 is
   2.485    ///of \c M2,
   2.486 @@ -624,7 +656,6 @@
   2.487    ///\c M1.
   2.488    ///The \c M2::Value must be convertible to \c M1::Key.
   2.489    ///\todo Check the requirements.
   2.490 -
   2.491    template <typename M1, typename M2> 
   2.492    class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
   2.493      const M1& m1;
   2.494 @@ -638,11 +669,12 @@
   2.495      ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
   2.496      
   2.497      typename MapTraits<M1>::ConstReturnValue
   2.498 +    /// \e
   2.499      operator[](Key k) const {return m1[m2[k]];}
   2.500    };
   2.501 -  ///Returns a \ref ComposeMap class
   2.502 +  ///Returns a \c ComposeMap class
   2.503  
   2.504 -  ///This function just returns a \ref ComposeMap class.
   2.505 +  ///This function just returns a \c ComposeMap class.
   2.506    ///
   2.507    ///\relates ComposeMap
   2.508    template <typename M1, typename M2> 
   2.509 @@ -655,7 +687,7 @@
   2.510    ///Combines of two maps using an STL (binary) functor.
   2.511    ///
   2.512    ///
   2.513 -  ///This \ref concepts::ReadMap "read only map" takes two maps and a
   2.514 +  ///This \c concepts::ReadMap "read only map" takes two maps and a
   2.515    ///binary functor and returns the composition of
   2.516    ///the two
   2.517    ///given maps unsing the functor. 
   2.518 @@ -672,10 +704,8 @@
   2.519    ///input parameter of \c F and the return type of \c F must be convertible
   2.520    ///to \c V.
   2.521    ///\todo Check the requirements.
   2.522 -
   2.523    template<typename M1, typename M2, typename F,
   2.524 -	   typename V = typename F::result_type,
   2.525 -	   typename NC = False> 
   2.526 +	   typename V = typename F::result_type> 
   2.527    class CombineMap : public MapBase<typename M1::Key, V> {
   2.528      const M1& m1;
   2.529      const M2& m2;
   2.530 @@ -686,26 +716,28 @@
   2.531      typedef typename Parent::Value Value;
   2.532  
   2.533      ///Constructor
   2.534 -    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f)
   2.535 +    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f = F())
   2.536        : m1(_m1), m2(_m2), f(_f) {};
   2.537 +    /// \e
   2.538      Value operator[](Key k) const {return f(m1[k],m2[k]);}
   2.539    };
   2.540    
   2.541 -  ///Returns a \ref CombineMap class
   2.542 +  ///Returns a \c CombineMap class
   2.543  
   2.544 -  ///This function just returns a \ref CombineMap class.
   2.545 -  ///
   2.546 -  ///Only the first template parameter (the value type) must be given.
   2.547 +  ///This function just returns a \c CombineMap class.
   2.548    ///
   2.549    ///For example if \c m1 and \c m2 are both \c double valued maps, then 
   2.550    ///\code
   2.551 -  ///combineMap<double>(m1,m2,std::plus<double>)
   2.552 +  ///combineMap<double>(m1,m2,std::plus<double>())
   2.553    ///\endcode
   2.554    ///is equivalent with
   2.555    ///\code
   2.556    ///addMap(m1,m2)
   2.557    ///\endcode
   2.558    ///
   2.559 +  ///This function is specialized for adaptable binary function
   2.560 +  ///classes and c++ functions.
   2.561 +  ///
   2.562    ///\relates CombineMap
   2.563    template<typename M1, typename M2, typename F, typename V> 
   2.564    inline CombineMap<M1, M2, F, V> 
   2.565 @@ -727,7 +759,7 @@
   2.566  
   2.567    ///Negative value of a map
   2.568  
   2.569 -  ///This \ref concepts::ReadMap "read only map" returns the negative
   2.570 +  ///This \c concepts::ReadMap "read only map" returns the negative
   2.571    ///value of the
   2.572    ///value returned by the
   2.573    ///given map. Its \c Key and \c Value will be inherited from \c M.
   2.574 @@ -743,12 +775,13 @@
   2.575  
   2.576      ///Constructor
   2.577      NegMap(const M &_m) : m(_m) {};
   2.578 +    /// \e
   2.579      Value operator[](Key k) const {return -m[k];}
   2.580    };
   2.581    
   2.582    ///Negative value of a map
   2.583  
   2.584 -  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
   2.585 +  ///This \c concepts::ReadWriteMap "read-write map" returns the negative
   2.586    ///value of the value returned by the
   2.587    ///given map. Its \c Key and \c Value will be inherited from \c M.
   2.588    ///The unary \c - operator must be defined for \c Value, of course.
   2.589 @@ -763,13 +796,15 @@
   2.590  
   2.591      ///Constructor
   2.592      NegWriteMap(M &_m) : m(_m) {};
   2.593 +    /// \e
   2.594      Value operator[](Key k) const {return -m[k];}
   2.595 +    /// \e
   2.596      void set(Key k, const Value& v) { m.set(k, -v); }
   2.597    };
   2.598  
   2.599 -  ///Returns a \ref NegMap class
   2.600 +  ///Returns a \c NegMap class
   2.601  
   2.602 -  ///This function just returns a \ref NegMap class.
   2.603 +  ///This function just returns a \c NegMap class.
   2.604    ///\relates NegMap
   2.605    template <typename M> 
   2.606    inline NegMap<M> negMap(const M &m) {
   2.607 @@ -783,7 +818,7 @@
   2.608  
   2.609    ///Absolute value of a map
   2.610  
   2.611 -  ///This \ref concepts::ReadMap "read only map" returns the absolute value
   2.612 +  ///This \c concepts::ReadMap "read only map" returns the absolute value
   2.613    ///of the
   2.614    ///value returned by the
   2.615    ///given map. Its \c Key and \c Value will be inherited
   2.616 @@ -814,6 +849,7 @@
   2.617  
   2.618      ///Constructor
   2.619      AbsMap(const M &_m) : m(_m) {};
   2.620 +    /// \e
   2.621      Value operator[](Key k) const {
   2.622        Value tmp = m[k]; 
   2.623        return tmp >= 0 ? tmp : -tmp;
   2.624 @@ -821,9 +857,9 @@
   2.625  
   2.626    };
   2.627    
   2.628 -  ///Returns a \ref AbsMap class
   2.629 +  ///Returns a \c AbsMap class
   2.630  
   2.631 -  ///This function just returns a \ref AbsMap class.
   2.632 +  ///This function just returns a \c AbsMap class.
   2.633    ///\relates AbsMap
   2.634    template<typename M> 
   2.635    inline AbsMap<M> absMap(const M &m) {
   2.636 @@ -832,7 +868,7 @@
   2.637  
   2.638    ///Converts an STL style functor to a map
   2.639  
   2.640 -  ///This \ref concepts::ReadMap "read only map" returns the value
   2.641 +  ///This \c concepts::ReadMap "read only map" returns the value
   2.642    ///of a
   2.643    ///given map.
   2.644    ///
   2.645 @@ -841,12 +877,9 @@
   2.646    ///because a functor does not provide such typedefs.
   2.647    ///
   2.648    ///Parameter \c F is the type of the used functor.
   2.649 -  
   2.650 -
   2.651    template<typename F, 
   2.652  	   typename K = typename F::argument_type, 
   2.653 -	   typename V = typename F::result_type,
   2.654 -	   typename NC = False> 
   2.655 +	   typename V = typename F::result_type> 
   2.656    class FunctorMap : public MapBase<K, V> {
   2.657      F f;
   2.658    public:
   2.659 @@ -855,16 +888,17 @@
   2.660      typedef typename Parent::Value Value;
   2.661  
   2.662      ///Constructor
   2.663 -    FunctorMap(const F &_f) : f(_f) {}
   2.664 -
   2.665 +    FunctorMap(const F &_f = F()) : f(_f) {}
   2.666 +    /// \e
   2.667      Value operator[](Key k) const { return f(k);}
   2.668    };
   2.669    
   2.670 -  ///Returns a \ref FunctorMap class
   2.671 +  ///Returns a \c FunctorMap class
   2.672  
   2.673 -  ///This function just returns a \ref FunctorMap class.
   2.674 +  ///This function just returns a \c FunctorMap class.
   2.675    ///
   2.676 -  ///The third template parameter isn't necessary to be given.
   2.677 +  ///It is specialized for adaptable function classes and
   2.678 +  ///c++ functions.
   2.679    ///\relates FunctorMap
   2.680    template<typename K, typename V, typename F> inline 
   2.681    FunctorMap<F, K, V> functorMap(const F &f) {
   2.682 @@ -890,9 +924,8 @@
   2.683    ///that is it provides an <tt>operator()</tt> to read its values.
   2.684    ///
   2.685    ///For the sake of convenience it also works as
   2.686 -  ///a ususal \ref concepts::ReadMap "readable map",
   2.687 +  ///a ususal \c concepts::ReadMap "readable map",
   2.688    ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
   2.689 -
   2.690    template <typename M> 
   2.691    class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
   2.692      const M& m;
   2.693 @@ -901,22 +934,20 @@
   2.694      typedef typename Parent::Key Key;
   2.695      typedef typename Parent::Value Value;
   2.696  
   2.697 -    ///\e
   2.698      typedef typename M::Key argument_type;
   2.699 -    ///\e
   2.700      typedef typename M::Value result_type;
   2.701  
   2.702      ///Constructor
   2.703      MapFunctor(const M &_m) : m(_m) {};
   2.704 -    ///Returns a value of the map
   2.705 +    ///\e
   2.706      Value operator()(Key k) const {return m[k];}
   2.707      ///\e
   2.708      Value operator[](Key k) const {return m[k];}
   2.709    };
   2.710    
   2.711 -  ///Returns a \ref MapFunctor class
   2.712 +  ///Returns a \c MapFunctor class
   2.713  
   2.714 -  ///This function just returns a \ref MapFunctor class.
   2.715 +  ///This function just returns a \c MapFunctor class.
   2.716    ///\relates MapFunctor
   2.717    template<typename M> 
   2.718    inline MapFunctor<M> mapFunctor(const M &m) {
   2.719 @@ -925,13 +956,12 @@
   2.720  
   2.721    ///Applies all map setting operations to two maps
   2.722  
   2.723 -  ///This map has two \ref concepts::ReadMap "readable map"
   2.724 +  ///This map has two \c concepts::ReadMap "readable map"
   2.725    ///parameters and each read request will be passed just to the
   2.726    ///first map. This class is the just readable map type of the ForkWriteMap.
   2.727    ///
   2.728    ///The \c Key and \c Value will be inherited from \c M1.
   2.729    ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
   2.730 -
   2.731    template<typename  M1, typename M2> 
   2.732    class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
   2.733      const M1& m1;
   2.734 @@ -943,21 +973,21 @@
   2.735  
   2.736      ///Constructor
   2.737      ForkMap(const M1 &_m1, const M2 &_m2) : m1(_m1), m2(_m2) {};
   2.738 +    /// \e
   2.739      Value operator[](Key k) const {return m1[k];}
   2.740    };
   2.741  
   2.742  
   2.743    ///Applies all map setting operations to two maps
   2.744  
   2.745 -  ///This map has two \ref concepts::WriteMap "writable map"
   2.746 +  ///This map has two \c concepts::WriteMap "writable map"
   2.747    ///parameters and each write request will be passed to both of them.
   2.748 -  ///If \c M1 is also \ref concepts::ReadMap "readable",
   2.749 +  ///If \c M1 is also \c concepts::ReadMap "readable",
   2.750    ///then the read operations will return the
   2.751    ///corresponding values of \c M1.
   2.752    ///
   2.753    ///The \c Key and \c Value will be inherited from \c M1.
   2.754    ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
   2.755 -
   2.756    template<typename  M1, typename M2> 
   2.757    class ForkWriteMap : public MapBase<typename M1::Key, typename M1::Value> {
   2.758      M1& m1;
   2.759 @@ -969,17 +999,17 @@
   2.760  
   2.761      ///Constructor
   2.762      ForkWriteMap(M1 &_m1, M2 &_m2) : m1(_m1), m2(_m2) {};
   2.763 +    ///\e
   2.764      Value operator[](Key k) const {return m1[k];}
   2.765 +    ///\e
   2.766      void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);}
   2.767    };
   2.768    
   2.769 -  ///Returns an \ref ForkMap class
   2.770 +  ///Returns an \c ForkMap class
   2.771  
   2.772 -  ///This function just returns an \ref ForkMap class.
   2.773 -  ///\todo How to call these type of functions?
   2.774 +  ///This function just returns an \c ForkMap class.
   2.775    ///
   2.776    ///\relates ForkMap
   2.777 -  ///\todo Wrong scope in Doxygen when \c \\relates is used
   2.778    template <typename M1, typename M2> 
   2.779    inline ForkMap<M1, M2> forkMap(const M1 &m1, const M2 &m2) {
   2.780      return ForkMap<M1, M2>(m1,m2);
   2.781 @@ -996,12 +1026,11 @@
   2.782    
   2.783    ///Logical 'not' of a map
   2.784    
   2.785 -  ///This bool \ref concepts::ReadMap "read only map" returns the 
   2.786 +  ///This bool \c concepts::ReadMap "read only map" returns the 
   2.787    ///logical negation of
   2.788    ///value returned by the
   2.789    ///given map. Its \c Key and will be inherited from \c M,
   2.790    ///its Value is <tt>bool</tt>.
   2.791 -
   2.792    template <typename M> 
   2.793    class NotMap : public MapBase<typename M::Key, bool> {
   2.794      const M& m;
   2.795 @@ -1012,12 +1041,13 @@
   2.796  
   2.797      /// Constructor
   2.798      NotMap(const M &_m) : m(_m) {};
   2.799 +    ///\e
   2.800      Value operator[](Key k) const {return !m[k];}
   2.801    };
   2.802  
   2.803    ///Logical 'not' of a map with writing possibility
   2.804    
   2.805 -  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
   2.806 +  ///This bool \c concepts::ReadWriteMap "read-write map" returns the 
   2.807    ///logical negation of value returned by the given map. When it is set,
   2.808    ///the opposite value is set to the original map.
   2.809    ///Its \c Key and will be inherited from \c M,
   2.810 @@ -1032,13 +1062,15 @@
   2.811  
   2.812      /// Constructor
   2.813      NotWriteMap(M &_m) : m(_m) {};
   2.814 +    ///\e
   2.815      Value operator[](Key k) const {return !m[k];}
   2.816 +    ///\e
   2.817      void set(Key k, bool v) { m.set(k, !v); }
   2.818    };
   2.819    
   2.820 -  ///Returns a \ref NotMap class
   2.821 +  ///Returns a \c NotMap class
   2.822    
   2.823 -  ///This function just returns a \ref NotMap class.
   2.824 +  ///This function just returns a \c NotMap class.
   2.825    ///\relates NotMap
   2.826    template <typename M> 
   2.827    inline NotMap<M> notMap(const M &m) {
   2.828 @@ -1277,7 +1309,6 @@
   2.829    ///   }
   2.830    /// }
   2.831    ///\endcode
   2.832 -
   2.833    template <typename Map>
   2.834    class FillBoolMap {
   2.835    public:
   2.836 @@ -1325,7 +1356,7 @@
   2.837    ///
   2.838    /// Writable bool map which stores for each true assigned elements  
   2.839    /// the setting order number. It make easy to calculate the leaving
   2.840 -  /// order of the nodes in the \ref dfs "Dfs" algorithm.
   2.841 +  /// order of the nodes in the \c Dfs algorithm.
   2.842    ///
   2.843    ///\code
   2.844    /// typedef Graph::NodeMap<int> OrderMap;