[Lemon-commits] deba: r3329 - in lemon/trunk: doc lemon

Lemon SVN svn at lemon.cs.elte.hu
Tue Oct 9 17:46:13 CEST 2007


Author: deba
Date: Tue Oct  9 17:46:12 2007
New Revision: 3329

Modified:
   lemon/trunk/doc/groups.dox
   lemon/trunk/lemon/maps.h

Log:
Bug fix and redesign StdMap
Improving map adaptors documentations



Modified: lemon/trunk/doc/groups.dox
==============================================================================
--- lemon/trunk/doc/groups.dox	(original)
+++ lemon/trunk/doc/groups.dox	Tue Oct  9 17:46:12 2007
@@ -97,6 +97,57 @@
 make arithmetic operations between one or two maps (negation, scaling,
 addition, multiplication etc.) or e.g. convert a map to another one
 of different Value type.
+
+The typical usage of this classes is the passing implicit maps to
+algorithms.  If a function type algorithm is called then the function
+type map adaptors can be used comfortable. For example let's see the
+usage of map adaptors with the \c graphToEps() function:
+\code
+  Color nodeColor(int deg) {
+    if (deg >= 2) {
+      return Color(0.5, 0.0, 0.5);
+    } else if (deg == 1) {
+      return Color(1.0, 0.5, 1.0);
+    } else {
+      return Color(0.0, 0.0, 0.0);
+    }
+  }
+  
+  Graph::NodeMap<int> degree_map(graph);
+  
+  graphToEps(graph, "graph.eps")
+    .coords(coords).scaleToA4().undirected()
+    .nodeColors(composeMap(functorMap(nodeColor), degree_map)) 
+    .run();
+\endcode 
+The \c functorMap() function makes an \c int to \c Color map from the
+\e nodeColor() function. The \c composeMap() compose the \e degree_map
+and the previous created map. The composed map is proper function to
+get color of each node.
+
+The usage with class type algorithms is little bit harder. In this
+case the function type map adaptors can not be used, because the
+function map adaptors give back temporarly objects.
+\code
+  Graph graph;
+  
+  typedef Graph::EdgeMap<double> DoubleEdgeMap;
+  DoubleEdgeMap length(graph);
+  DoubleEdgeMap speed(graph);
+  
+  typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap;
+  
+  TimeMap time(length, speed);
+  
+  Dijkstra<Graph, TimeMap> dijkstra(graph, time);
+  dijkstra.run(source, target);
+\endcode
+
+We have a length map and a maximum speed map on a graph. The minimum
+time to pass the edge can be calculated as the division of the two
+maps which can be done implicitly with the \c DivMap template
+class. We use the implicit minimum time map as the length map of the
+\c Dijkstra algorithm.
 */
 
 /**
@@ -115,9 +166,10 @@
 LEMON provides flexible data structures
 to work with paths.
 
-All of them have the same interface, especially they can be built or extended
-using a standard Builder subclass. This make is easy to have e.g. the Dijkstra
-algorithm to store its result in any kind of path structure.
+All of them have similar interfaces, and it can be copied easily with
+assignment operator and copy constructor. This make it easy and
+efficient to have e.g. the Dijkstra algorithm to store its result in
+any kind of path structure.
 
 \sa lemon::concepts::Path
 

Modified: lemon/trunk/lemon/maps.h
==============================================================================
--- lemon/trunk/lemon/maps.h	(original)
+++ lemon/trunk/lemon/maps.h	Tue Oct  9 17:46:12 2007
@@ -29,9 +29,6 @@
 ///\ingroup maps
 ///\brief Miscellaneous property maps
 ///
-///\todo This file has the same name as the concept file in concepts/,
-/// and this is not easily detectable in docs...
-
 #include <map>
 
 namespace lemon {
@@ -79,8 +76,7 @@
   /// Constant map.
 
   /// This is a readable map which assigns a specified value to each key.
-  /// In other aspects it is equivalent to the \ref NullMap.
-  /// \todo set could be used to set the value.
+  /// In other aspects it is equivalent to the \c NullMap.
   template<typename K, typename T>
   class ConstMap : public MapBase<K, T> {
   private:
@@ -101,9 +97,14 @@
     /// \param _v The initial value of the map.
     ///
     ConstMap(const T &_v) : v(_v) {}
-
+    
+    ///\e
     T operator[](const K&) const { return v; }
-    void set(const K&, const T&) {}
+
+    ///\e
+    void setAll(const T &t) {
+      v = t;
+    }    
 
     template<typename T1>
     struct rebind {
@@ -114,9 +115,9 @@
     ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
   };
 
-  ///Returns a \ref ConstMap class
+  ///Returns a \c ConstMap class
 
-  ///This function just returns a \ref ConstMap class.
+  ///This function just returns a \c ConstMap class.
   ///\relates ConstMap
   template<typename K, typename V> 
   inline ConstMap<K, V> constMap(const V &v) {
@@ -124,11 +125,13 @@
   }
 
 
-  //\todo to document later
   template<typename T, T v>
   struct Const { };
 
-  //\todo to document later
+  /// Constant map with inlined constant value.
+
+  /// This is a readable map which assigns a specified value to each key.
+  /// In other aspects it is equivalent to the \c NullMap.
   template<typename K, typename V, V v>
   class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
   public:
@@ -137,32 +140,32 @@
     typedef typename Parent::Value Value;
 
     ConstMap() { }
+    ///\e
     V operator[](const K&) const { return v; }
+    ///\e
     void set(const K&, const V&) { }
   };
 
-  ///Returns a \ref ConstMap class
+  ///Returns a \c ConstMap class
 
-  ///This function just returns a \ref ConstMap class.
+  ///This function just returns a \c ConstMap class with inlined value.
   ///\relates ConstMap
   template<typename K, typename V, V v> 
   inline ConstMap<K, Const<V, v> > constMap() {
     return ConstMap<K, Const<V, v> >();
   }
 
-  /// \c std::map wrapper
+  ///Map based on std::map
 
-  /// This is essentially a wrapper for \c std::map. With addition that
-  /// you can specify a default value different from \c Value() .
-  ///
-  /// \todo Provide allocator parameter...
+  ///This is essentially a wrapper for \c std::map. With addition that
+  ///you can specify a default value different from \c Value() .
   template <typename K, typename T, typename Compare = std::less<K> >
-  class StdMap : public std::map<K, T, Compare> {
-    typedef std::map<K, T, Compare> parent;
-    T v;
-    typedef typename parent::value_type PairType;
-
+  class StdMap {
+    template <typename K1, typename T1, typename C1>
+    friend class StdMap;
   public:
+
+    typedef True ReferenceMapTag;
     ///\e
     typedef K Key;
     ///\e
@@ -172,50 +175,69 @@
     ///\e
     typedef const T& ConstReference;
 
+  private:
+    
+    typedef std::map<K, T, Compare> Map;
+    Value _value;
+    Map _map;
 
-    StdMap() : v() {}
-    /// Constructor with specified default value
-    StdMap(const T& _v) : v(_v) {}
+  public:
 
-    /// \brief Constructs the map from an appropriate std::map.
-    ///
-    /// \warning Inefficient: copies the content of \c m !
-    StdMap(const parent &m) : parent(m) {}
+    /// Constructor with specified default value
+    StdMap(const T& value = T()) : _value(value) {}
     /// \brief Constructs the map from an appropriate std::map, and explicitly
     /// specifies a default value.
-    ///
-    /// \warning Inefficient: copies the content of \c m !
-    StdMap(const parent &m, const T& _v) : parent(m), v(_v) {}
+    template <typename T1, typename Comp1>
+    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
+      : _map(map.begin(), map.end()), _value(value) {}
     
+    /// \brief Constructs a map from an other StdMap.
     template<typename T1, typename Comp1>
-    StdMap(const StdMap<Key, T1,Comp1> &m, const T &_v) { 
-      //FIXME; 
-    }
+    StdMap(const StdMap<Key, T1, Comp1> &c) 
+      : _map(c._map.begin(), c._map.end()), _value(c._value) {}
+
+  private:
+
+    StdMap& operator=(const StdMap&);
 
+  public:
+
+    ///\e
     Reference operator[](const Key &k) {
-      return insert(PairType(k,v)).first -> second;
+      typename Map::iterator it = _map.lower_bound(k);
+      if (it != _map.end() && !_map.key_comp()(k, it->first))
+	return it->second;
+      else
+	return _map.insert(it, std::make_pair(k, _value))->second;
     }
 
+    /// \e 
     ConstReference operator[](const Key &k) const {
-      typename parent::iterator i = lower_bound(k);
-      if (i == parent::end() || parent::key_comp()(k, (*i).first))
-	return v;
-      return (*i).second;
+      typename Map::const_iterator it = _map.find(k);
+      if (it != _map.end())
+	return it->second;
+      else
+	return _value;
     }
+
+    /// \e 
     void set(const Key &k, const T &t) {
-      parent::operator[](k) = t;
+      typename Map::iterator it = _map.lower_bound(k);
+      if (it != _map.end() && !_map.key_comp()(k, it->first))
+	it->second = t;
+      else
+	_map.insert(it, std::make_pair(k, t));
     }
 
-    /// Changes the default value of the map.
-    /// \return Returns the previous default value.
-    ///
-    /// \warning The value of some keys (which has already been queried, but
-    /// the value has been unchanged from the default) may change!
-    T setDefault(const T &_v) { T old=v; v=_v; return old; }
+    /// \e
+    void setAll(const T &t) {
+      _value = t;
+      _map.clear();
+    }    
 
-    template<typename T1>
+    template <typename T1, typename C1 = std::less<T1> >
     struct rebind {
-      typedef StdMap<Key, T1,Compare> other;
+      typedef StdMap<Key, T1, C1> other;
     };
   };
 
@@ -235,14 +257,15 @@
     typedef typename Parent::Key Key;
     typedef typename Parent::Value Value;
 
+    /// \e
     const T& operator[](const T& t) const {
       return t;
     }
   };
 
-  ///Returns an \ref IdentityMap class
+  ///Returns an \c IdentityMap class
 
-  ///This function just returns an \ref IdentityMap class.
+  ///This function just returns an \c IdentityMap class.
   ///\relates IdentityMap
   template<typename T>
   inline IdentityMap<T> identityMap() {
@@ -252,7 +275,7 @@
 
   ///Convert the \c Value of a map to another type.
 
-  ///This \ref concepts::ReadMap "read only map"
+  ///This \c concepts::ReadMap "read only map"
   ///converts the \c Value of a maps to type \c T.
   ///Its \c Key is inherited from \c M.
   template <typename M, typename T> 
@@ -277,11 +300,10 @@
     Value operator[](const Key& k) const {return m[k];}
   };
   
-  ///Returns an \ref ConvertMap class
+  ///Returns an \c ConvertMap class
 
-  ///This function just returns an \ref ConvertMap class.
+  ///This function just returns an \c ConvertMap class.
   ///\relates ConvertMap
-  ///\todo The order of the template parameters are changed.
   template<typename T, typename M>
   inline ConvertMap<M, T> convertMap(const M &m) {
     return ConvertMap<M, T>(m);
@@ -289,7 +311,7 @@
 
   ///Simple wrapping of the map
 
-  ///This \ref concepts::ReadMap "read only map" returns the simple
+  ///This \c concepts::ReadMap "read only map" returns the simple
   ///wrapping of the given map. Sometimes the reference maps cannot be
   ///combined with simple read maps. This map adaptor wraps the given
   ///map to simple read map.
@@ -304,12 +326,13 @@
 
     ///Constructor
     SimpleMap(const M &_m) : m(_m) {};
+    ///\e
     Value operator[](Key k) const {return m[k];}
   };
 
   ///Simple writeable wrapping of the map
 
-  ///This \ref concepts::ReadMap "read only map" returns the simple
+  ///This \c concepts::ReadMap "read only map" returns the simple
   ///wrapping of the given map. Sometimes the reference maps cannot be
   ///combined with simple read-write maps. This map adaptor wraps the
   ///given map to simple read-write map.
@@ -324,13 +347,15 @@
 
     ///Constructor
     SimpleWriteMap(M &_m) : m(_m) {};
+    ///\e
     Value operator[](Key k) const {return m[k];}
+    ///\e
     void set(Key k, const Value& c) { m.set(k, c); }
   };
 
   ///Sum of two maps
 
-  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
+  ///This \c concepts::ReadMap "read only map" returns the sum of the two
   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
 
@@ -346,16 +371,16 @@
 
     ///Constructor
     AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
+    ///\e
     Value operator[](Key k) const {return m1[k]+m2[k];}
   };
   
-  ///Returns an \ref AddMap class
+  ///Returns an \c AddMap class
 
-  ///This function just returns an \ref AddMap class.
+  ///This function just returns an \c AddMap class.
   ///\todo How to call these type of functions?
   ///
   ///\relates AddMap
-  ///\todo Wrong scope in Doxygen when \c \\relates is used
   template<typename M1, typename M2> 
   inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
     return AddMap<M1, M2>(m1,m2);
@@ -363,7 +388,7 @@
 
   ///Shift a map with a constant.
 
-  ///This \ref concepts::ReadMap "read only map" returns the sum of the
+  ///This \c concepts::ReadMap "read only map" returns the sum of the
   ///given map and a constant value.
   ///Its \c Key and \c Value is inherited from \c M.
   ///
@@ -391,12 +416,13 @@
     ///\param _m is the undelying map
     ///\param _v is the shift value
     ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
+    ///\e
     Value operator[](Key k) const {return m[k] + v;}
   };
 
   ///Shift a map with a constant.
 
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
+  ///This \c concepts::ReadWriteMap "read-write map" returns the sum of the
   ///given map and a constant value. It makes also possible to write the map.
   ///Its \c Key and \c Value is inherited from \c M.
   ///
@@ -424,15 +450,16 @@
     ///\param _m is the undelying map
     ///\param _v is the shift value
     ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
+    /// \e
     Value operator[](Key k) const {return m[k] + v;}
+    /// \e
     void set(Key k, const Value& c) { m.set(k, c - v); }
   };
   
-  ///Returns an \ref ShiftMap class
+  ///Returns an \c ShiftMap class
 
-  ///This function just returns an \ref ShiftMap class.
+  ///This function just returns an \c ShiftMap class.
   ///\relates ShiftMap
-  ///\todo A better name is required.
   template<typename M, typename C> 
   inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
     return ShiftMap<M, C>(m,v);
@@ -445,7 +472,7 @@
 
   ///Difference of two maps
 
-  ///This \ref concepts::ReadMap "read only map" returns the difference
+  ///This \c concepts::ReadMap "read only map" returns the difference
   ///of the values of the two
   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
@@ -461,12 +488,13 @@
 
     ///Constructor
     SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
+    /// \e
     Value operator[](Key k) const {return m1[k]-m2[k];}
   };
   
-  ///Returns a \ref SubMap class
+  ///Returns a \c SubMap class
 
-  ///This function just returns a \ref SubMap class.
+  ///This function just returns a \c SubMap class.
   ///
   ///\relates SubMap
   template<typename M1, typename M2> 
@@ -476,7 +504,7 @@
 
   ///Product of two maps
 
-  ///This \ref concepts::ReadMap "read only map" returns the product of the
+  ///This \c concepts::ReadMap "read only map" returns the product of the
   ///values of the two
   ///given
   ///maps. Its \c Key and \c Value will be inherited from \c M1.
@@ -493,12 +521,13 @@
 
     ///Constructor
     MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
+    /// \e
     Value operator[](Key k) const {return m1[k]*m2[k];}
   };
   
-  ///Returns a \ref MulMap class
+  ///Returns a \c MulMap class
 
-  ///This function just returns a \ref MulMap class.
+  ///This function just returns a \c MulMap class.
   ///\relates MulMap
   template<typename M1, typename M2> 
   inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
@@ -507,7 +536,7 @@
  
   ///Scales a maps with a constant.
 
-  ///This \ref concepts::ReadMap "read only map" returns the value of the
+  ///This \c concepts::ReadMap "read only map" returns the value of the
   ///given map multiplied from the left side with a constant value.
   ///Its \c Key and \c Value is inherited from \c M.
   ///
@@ -535,12 +564,13 @@
     ///\param _m is the undelying map
     ///\param _v is the scaling value
     ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
+    /// \e
     Value operator[](Key k) const {return v * m[k];}
   };
 
   ///Scales a maps with a constant.
 
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
+  ///This \c concepts::ReadWriteMap "read-write map" returns the value of the
   ///given map multiplied from the left side with a constant value. It can
   ///be used as write map also if the given multiplier is not zero.
   ///Its \c Key and \c Value is inherited from \c M.
@@ -559,15 +589,16 @@
     ///\param _m is the undelying map
     ///\param _v is the scaling value
     ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
+    /// \e
     Value operator[](Key k) const {return v * m[k];}
+    /// \e
     void set(Key k, const Value& c) { m.set(k, c / v);}
   };
   
-  ///Returns an \ref ScaleMap class
+  ///Returns an \c ScaleMap class
 
-  ///This function just returns an \ref ScaleMap class.
+  ///This function just returns an \c ScaleMap class.
   ///\relates ScaleMap
-  ///\todo A better name is required.
   template<typename M, typename C> 
   inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
     return ScaleMap<M, C>(m,v);
@@ -580,7 +611,7 @@
 
   ///Quotient of two maps
 
-  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
+  ///This \c concepts::ReadMap "read only map" returns the quotient of the
   ///values of the two
   ///given maps. Its \c Key and \c Value will be inherited from \c M1.
   ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
@@ -596,12 +627,13 @@
 
     ///Constructor
     DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
+    /// \e
     Value operator[](Key k) const {return m1[k]/m2[k];}
   };
   
-  ///Returns a \ref DivMap class
+  ///Returns a \c DivMap class
 
-  ///This function just returns a \ref DivMap class.
+  ///This function just returns a \c DivMap class.
   ///\relates DivMap
   template<typename M1, typename M2> 
   inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
@@ -610,7 +642,7 @@
   
   ///Composition of two maps
 
-  ///This \ref concepts::ReadMap "read only map" returns the composition of
+  ///This \c concepts::ReadMap "read only map" returns the composition of
   ///two
   ///given maps. That is to say, if \c m1 is of type \c M1 and \c m2 is
   ///of \c M2,
@@ -624,7 +656,6 @@
   ///\c M1.
   ///The \c M2::Value must be convertible to \c M1::Key.
   ///\todo Check the requirements.
-
   template <typename M1, typename M2> 
   class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
     const M1& m1;
@@ -638,11 +669,12 @@
     ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
     
     typename MapTraits<M1>::ConstReturnValue
+    /// \e
     operator[](Key k) const {return m1[m2[k]];}
   };
-  ///Returns a \ref ComposeMap class
+  ///Returns a \c ComposeMap class
 
-  ///This function just returns a \ref ComposeMap class.
+  ///This function just returns a \c ComposeMap class.
   ///
   ///\relates ComposeMap
   template <typename M1, typename M2> 
@@ -655,7 +687,7 @@
   ///Combines of two maps using an STL (binary) functor.
   ///
   ///
-  ///This \ref concepts::ReadMap "read only map" takes two maps and a
+  ///This \c concepts::ReadMap "read only map" takes two maps and a
   ///binary functor and returns the composition of
   ///the two
   ///given maps unsing the functor. 
@@ -672,10 +704,8 @@
   ///input parameter of \c F and the return type of \c F must be convertible
   ///to \c V.
   ///\todo Check the requirements.
-
   template<typename M1, typename M2, typename F,
-	   typename V = typename F::result_type,
-	   typename NC = False> 
+	   typename V = typename F::result_type> 
   class CombineMap : public MapBase<typename M1::Key, V> {
     const M1& m1;
     const M2& m2;
@@ -686,26 +716,28 @@
     typedef typename Parent::Value Value;
 
     ///Constructor
-    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f)
+    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f = F())
       : m1(_m1), m2(_m2), f(_f) {};
+    /// \e
     Value operator[](Key k) const {return f(m1[k],m2[k]);}
   };
   
-  ///Returns a \ref CombineMap class
+  ///Returns a \c CombineMap class
 
-  ///This function just returns a \ref CombineMap class.
-  ///
-  ///Only the first template parameter (the value type) must be given.
+  ///This function just returns a \c CombineMap class.
   ///
   ///For example if \c m1 and \c m2 are both \c double valued maps, then 
   ///\code
-  ///combineMap<double>(m1,m2,std::plus<double>)
+  ///combineMap<double>(m1,m2,std::plus<double>())
   ///\endcode
   ///is equivalent with
   ///\code
   ///addMap(m1,m2)
   ///\endcode
   ///
+  ///This function is specialized for adaptable binary function
+  ///classes and c++ functions.
+  ///
   ///\relates CombineMap
   template<typename M1, typename M2, typename F, typename V> 
   inline CombineMap<M1, M2, F, V> 
@@ -727,7 +759,7 @@
 
   ///Negative value of a map
 
-  ///This \ref concepts::ReadMap "read only map" returns the negative
+  ///This \c concepts::ReadMap "read only map" returns the negative
   ///value of the
   ///value returned by the
   ///given map. Its \c Key and \c Value will be inherited from \c M.
@@ -743,12 +775,13 @@
 
     ///Constructor
     NegMap(const M &_m) : m(_m) {};
+    /// \e
     Value operator[](Key k) const {return -m[k];}
   };
   
   ///Negative value of a map
 
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
+  ///This \c concepts::ReadWriteMap "read-write map" returns the negative
   ///value of the value returned by the
   ///given map. Its \c Key and \c Value will be inherited from \c M.
   ///The unary \c - operator must be defined for \c Value, of course.
@@ -763,13 +796,15 @@
 
     ///Constructor
     NegWriteMap(M &_m) : m(_m) {};
+    /// \e
     Value operator[](Key k) const {return -m[k];}
+    /// \e
     void set(Key k, const Value& v) { m.set(k, -v); }
   };
 
-  ///Returns a \ref NegMap class
+  ///Returns a \c NegMap class
 
-  ///This function just returns a \ref NegMap class.
+  ///This function just returns a \c NegMap class.
   ///\relates NegMap
   template <typename M> 
   inline NegMap<M> negMap(const M &m) {
@@ -783,7 +818,7 @@
 
   ///Absolute value of a map
 
-  ///This \ref concepts::ReadMap "read only map" returns the absolute value
+  ///This \c concepts::ReadMap "read only map" returns the absolute value
   ///of the
   ///value returned by the
   ///given map. Its \c Key and \c Value will be inherited
@@ -814,6 +849,7 @@
 
     ///Constructor
     AbsMap(const M &_m) : m(_m) {};
+    /// \e
     Value operator[](Key k) const {
       Value tmp = m[k]; 
       return tmp >= 0 ? tmp : -tmp;
@@ -821,9 +857,9 @@
 
   };
   
-  ///Returns a \ref AbsMap class
+  ///Returns a \c AbsMap class
 
-  ///This function just returns a \ref AbsMap class.
+  ///This function just returns a \c AbsMap class.
   ///\relates AbsMap
   template<typename M> 
   inline AbsMap<M> absMap(const M &m) {
@@ -832,7 +868,7 @@
 
   ///Converts an STL style functor to a map
 
-  ///This \ref concepts::ReadMap "read only map" returns the value
+  ///This \c concepts::ReadMap "read only map" returns the value
   ///of a
   ///given map.
   ///
@@ -841,12 +877,9 @@
   ///because a functor does not provide such typedefs.
   ///
   ///Parameter \c F is the type of the used functor.
-  
-
   template<typename F, 
 	   typename K = typename F::argument_type, 
-	   typename V = typename F::result_type,
-	   typename NC = False> 
+	   typename V = typename F::result_type> 
   class FunctorMap : public MapBase<K, V> {
     F f;
   public:
@@ -855,16 +888,17 @@
     typedef typename Parent::Value Value;
 
     ///Constructor
-    FunctorMap(const F &_f) : f(_f) {}
-
+    FunctorMap(const F &_f = F()) : f(_f) {}
+    /// \e
     Value operator[](Key k) const { return f(k);}
   };
   
-  ///Returns a \ref FunctorMap class
+  ///Returns a \c FunctorMap class
 
-  ///This function just returns a \ref FunctorMap class.
+  ///This function just returns a \c FunctorMap class.
   ///
-  ///The third template parameter isn't necessary to be given.
+  ///It is specialized for adaptable function classes and
+  ///c++ functions.
   ///\relates FunctorMap
   template<typename K, typename V, typename F> inline 
   FunctorMap<F, K, V> functorMap(const F &f) {
@@ -890,9 +924,8 @@
   ///that is it provides an <tt>operator()</tt> to read its values.
   ///
   ///For the sake of convenience it also works as
-  ///a ususal \ref concepts::ReadMap "readable map",
+  ///a ususal \c concepts::ReadMap "readable map",
   ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
-
   template <typename M> 
   class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
     const M& m;
@@ -901,22 +934,20 @@
     typedef typename Parent::Key Key;
     typedef typename Parent::Value Value;
 
-    ///\e
     typedef typename M::Key argument_type;
-    ///\e
     typedef typename M::Value result_type;
 
     ///Constructor
     MapFunctor(const M &_m) : m(_m) {};
-    ///Returns a value of the map
+    ///\e
     Value operator()(Key k) const {return m[k];}
     ///\e
     Value operator[](Key k) const {return m[k];}
   };
   
-  ///Returns a \ref MapFunctor class
+  ///Returns a \c MapFunctor class
 
-  ///This function just returns a \ref MapFunctor class.
+  ///This function just returns a \c MapFunctor class.
   ///\relates MapFunctor
   template<typename M> 
   inline MapFunctor<M> mapFunctor(const M &m) {
@@ -925,13 +956,12 @@
 
   ///Applies all map setting operations to two maps
 
-  ///This map has two \ref concepts::ReadMap "readable map"
+  ///This map has two \c concepts::ReadMap "readable map"
   ///parameters and each read request will be passed just to the
   ///first map. This class is the just readable map type of the ForkWriteMap.
   ///
   ///The \c Key and \c Value will be inherited from \c M1.
   ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
-
   template<typename  M1, typename M2> 
   class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
     const M1& m1;
@@ -943,21 +973,21 @@
 
     ///Constructor
     ForkMap(const M1 &_m1, const M2 &_m2) : m1(_m1), m2(_m2) {};
+    /// \e
     Value operator[](Key k) const {return m1[k];}
   };
 
 
   ///Applies all map setting operations to two maps
 
-  ///This map has two \ref concepts::WriteMap "writable map"
+  ///This map has two \c concepts::WriteMap "writable map"
   ///parameters and each write request will be passed to both of them.
-  ///If \c M1 is also \ref concepts::ReadMap "readable",
+  ///If \c M1 is also \c concepts::ReadMap "readable",
   ///then the read operations will return the
   ///corresponding values of \c M1.
   ///
   ///The \c Key and \c Value will be inherited from \c M1.
   ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
-
   template<typename  M1, typename M2> 
   class ForkWriteMap : public MapBase<typename M1::Key, typename M1::Value> {
     M1& m1;
@@ -969,17 +999,17 @@
 
     ///Constructor
     ForkWriteMap(M1 &_m1, M2 &_m2) : m1(_m1), m2(_m2) {};
+    ///\e
     Value operator[](Key k) const {return m1[k];}
+    ///\e
     void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);}
   };
   
-  ///Returns an \ref ForkMap class
+  ///Returns an \c ForkMap class
 
-  ///This function just returns an \ref ForkMap class.
-  ///\todo How to call these type of functions?
+  ///This function just returns an \c ForkMap class.
   ///
   ///\relates ForkMap
-  ///\todo Wrong scope in Doxygen when \c \\relates is used
   template <typename M1, typename M2> 
   inline ForkMap<M1, M2> forkMap(const M1 &m1, const M2 &m2) {
     return ForkMap<M1, M2>(m1,m2);
@@ -996,12 +1026,11 @@
   
   ///Logical 'not' of a map
   
-  ///This bool \ref concepts::ReadMap "read only map" returns the 
+  ///This bool \c concepts::ReadMap "read only map" returns the 
   ///logical negation of
   ///value returned by the
   ///given map. Its \c Key and will be inherited from \c M,
   ///its Value is <tt>bool</tt>.
-
   template <typename M> 
   class NotMap : public MapBase<typename M::Key, bool> {
     const M& m;
@@ -1012,12 +1041,13 @@
 
     /// Constructor
     NotMap(const M &_m) : m(_m) {};
+    ///\e
     Value operator[](Key k) const {return !m[k];}
   };
 
   ///Logical 'not' of a map with writing possibility
   
-  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
+  ///This bool \c concepts::ReadWriteMap "read-write map" returns the 
   ///logical negation of value returned by the given map. When it is set,
   ///the opposite value is set to the original map.
   ///Its \c Key and will be inherited from \c M,
@@ -1032,13 +1062,15 @@
 
     /// Constructor
     NotWriteMap(M &_m) : m(_m) {};
+    ///\e
     Value operator[](Key k) const {return !m[k];}
+    ///\e
     void set(Key k, bool v) { m.set(k, !v); }
   };
   
-  ///Returns a \ref NotMap class
+  ///Returns a \c NotMap class
   
-  ///This function just returns a \ref NotMap class.
+  ///This function just returns a \c NotMap class.
   ///\relates NotMap
   template <typename M> 
   inline NotMap<M> notMap(const M &m) {
@@ -1277,7 +1309,6 @@
   ///   }
   /// }
   ///\endcode
-
   template <typename Map>
   class FillBoolMap {
   public:
@@ -1325,7 +1356,7 @@
   ///
   /// Writable bool map which stores for each true assigned elements  
   /// the setting order number. It make easy to calculate the leaving
-  /// order of the nodes in the \ref dfs "Dfs" algorithm.
+  /// order of the nodes in the \c Dfs algorithm.
   ///
   ///\code
   /// typedef Graph::NodeMap<int> OrderMap;



More information about the Lemon-commits mailing list