# HG changeset patch # User deba # Date 1191944772 0 # Node ID 48dddc283cfc1cc0980a68fd2b276b302e43a7ed # Parent da94e3b332f3d5fa4b84a3e824035931c1266ee2 Bug fix and redesign StdMap Improving map adaptors documentations diff -r da94e3b332f3 -r 48dddc283cfc doc/groups.dox --- a/doc/groups.dox Tue Oct 09 09:36:54 2007 +0000 +++ b/doc/groups.dox Tue Oct 09 15:46:12 2007 +0000 @@ -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 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 DoubleEdgeMap; + DoubleEdgeMap length(graph); + DoubleEdgeMap speed(graph); + + typedef DivMap TimeMap; + + TimeMap time(length, speed); + + Dijkstra 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 diff -r da94e3b332f3 -r 48dddc283cfc lemon/maps.h --- a/lemon/maps.h Tue Oct 09 09:36:54 2007 +0000 +++ b/lemon/maps.h Tue Oct 09 15:46:12 2007 +0000 @@ -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 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 class ConstMap : public MapBase { 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; } - T operator[](const K&) const { return v; } - void set(const K&, const T&) {} + ///\e + void setAll(const T &t) { + v = t; + } template struct rebind { @@ -114,9 +115,9 @@ ConstMap(const ConstMap &, 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 inline ConstMap constMap(const V &v) { @@ -124,11 +125,13 @@ } - //\todo to document later template 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 class ConstMap > : public MapBase { 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 inline ConstMap > constMap() { return ConstMap >(); } - /// \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 > - class StdMap : public std::map { - typedef std::map parent; - T v; - typedef typename parent::value_type PairType; + class StdMap { + template + friend class StdMap; + public: - public: + typedef True ReferenceMapTag; ///\e typedef K Key; ///\e @@ -172,50 +175,69 @@ ///\e typedef const T& ConstReference; + private: + + typedef std::map Map; + Value _value; + Map _map; - StdMap() : v() {} + public: + /// Constructor with specified default value - StdMap(const T& _v) : v(_v) {} - - /// \brief Constructs the map from an appropriate std::map. - /// - /// \warning Inefficient: copies the content of \c m ! - StdMap(const parent &m) : parent(m) {} + 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 + StdMap(const std::map &map, const T& value = T()) + : _map(map.begin(), map.end()), _value(value) {} + /// \brief Constructs a map from an other StdMap. template - StdMap(const StdMap &m, const T &_v) { - //FIXME; + StdMap(const StdMap &c) + : _map(c._map.begin(), c._map.end()), _value(c._value) {} + + private: + + StdMap& operator=(const StdMap&); + + public: + + ///\e + Reference operator[](const Key &k) { + 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; } - Reference operator[](const Key &k) { - return insert(PairType(k,v)).first -> second; + /// \e + ConstReference operator[](const Key &k) const { + typename Map::const_iterator it = _map.find(k); + if (it != _map.end()) + return it->second; + else + return _value; } - 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; - } + /// \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 + template > struct rebind { - typedef StdMap other; + typedef StdMap 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 inline IdentityMap 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 @@ -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 inline ConvertMap convertMap(const M &m) { return ConvertMap(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 inline AddMap addMap(const M1 &m1,const M2 &m2) { return AddMap(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 inline ShiftMap shiftMap(const M &m,const C &v) { return ShiftMap(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 @@ -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 inline MulMap 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 inline ScaleMap scaleMap(const M &m,const C &v) { return ScaleMap(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 inline DivMap 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 class ComposeMap : public MapBase { const M1& m1; @@ -638,11 +669,12 @@ ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; typename MapTraits::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 @@ -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 V = typename F::result_type> class CombineMap : public MapBase { 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(m1,m2,std::plus) + ///combineMap(m1,m2,std::plus()) ///\endcode ///is equivalent with ///\code ///addMap(m1,m2) ///\endcode /// + ///This function is specialized for adaptable binary function + ///classes and c++ functions. + /// ///\relates CombineMap template inline CombineMap @@ -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 inline NegMap 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 inline AbsMap 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 V = typename F::result_type> class FunctorMap : public MapBase { 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 inline FunctorMap functorMap(const F &f) { @@ -890,9 +924,8 @@ ///that is it provides an operator() 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. operator[] and the \c Key and \c Value typedefs also exist. - template class MapFunctor : public MapBase { 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 inline MapFunctor 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 class ForkMap : public MapBase { 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 class ForkWriteMap : public MapBase { 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 inline ForkMap forkMap(const M1 &m1, const M2 &m2) { return ForkMap(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 bool. - template class NotMap : public MapBase { 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 inline NotMap notMap(const M &m) { @@ -1277,7 +1309,6 @@ /// } /// } ///\endcode - template 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 OrderMap;