diff -r 17e76967c49f -r bc69cdfe171c lemon/maps.h --- a/lemon/maps.h Mon Jan 07 16:24:39 2008 +0100 +++ b/lemon/maps.h Mon Jan 07 23:36:33 2008 +0100 @@ -163,21 +163,23 @@ ///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 { + class StdMap : public MapBase { template friend class StdMap; public: - typedef True ReferenceMapTag; + typedef MapBase Parent; ///\e - typedef K Key; + typedef typename Parent::Key Key; ///\e - typedef T Value; + typedef typename Parent::Value Value; ///\e typedef T& Reference; ///\e typedef const T& ConstReference; + typedef True ReferenceMapTag; + private: typedef std::map Map; @@ -239,6 +241,27 @@ } }; + + ///Returns a \ref StdMap class + + ///This function just returns a \ref StdMap class with specified + ///default value. + ///\relates StdMap + template > + inline StdMap stdMap(const V& value = V()) { + return StdMap(value); + } + + ///Returns a \ref StdMap class created from an appropriate std::map + + ///This function just returns a \ref StdMap class created from an + ///appropriate std::map. + ///\relates StdMap + template > + inline StdMap stdMap( const std::map &map, + const V& value = V() ) { + return StdMap(map, value); + } /// \brief Map for storing values for keys from the range [0..size-1] /// @@ -249,23 +272,25 @@ /// /// \todo Revise its name template - class IntegerMap { + class IntegerMap : public MapBase { template friend class IntegerMap; public: - typedef True ReferenceMapTag; + typedef MapBase Parent; ///\e - typedef int Key; + typedef typename Parent::Key Key; ///\e - typedef T Value; + typedef typename Parent::Value Value; ///\e typedef T& Reference; ///\e typedef const T& ConstReference; + typedef True ReferenceMapTag; + private: typedef std::vector Vector; @@ -313,6 +338,15 @@ } }; + + ///Returns an \ref IntegerMap class + + ///This function just returns an \ref IntegerMap class. + ///\relates IntegerMap + template + inline IntegerMap integerMap(int size = 0, const T& value = T()) { + return IntegerMap(size, value); + } /// @} @@ -405,6 +439,15 @@ ///\e Value operator[](Key k) const {return m[k];} }; + + ///Returns a \ref SimpleMap class + + ///This function just returns a \ref SimpleMap class. + ///\relates SimpleMap + template + inline SimpleMap simpleMap(const M &m) { + return SimpleMap(m); + } ///Simple writable wrapping of a map @@ -433,6 +476,15 @@ void set(Key k, const Value& c) { m.set(k, c); } }; + ///Returns a \ref SimpleWriteMap class + + ///This function just returns a \ref SimpleWriteMap class. + ///\relates SimpleWriteMap + template + inline SimpleWriteMap simpleWriteMap(M &m) { + return SimpleWriteMap(m); + } + ///Sum of two maps ///This \c concepts::ReadMap "read only map" returns the sum of the two