# HG changeset patch # User Peter Kovacs # Date 1253874162 -7200 # Node ID d8073df341f625e4a519b40e6903ac83539c2f73 # Parent acdd0bd75a55f3844e955aa37a69522457b193a7 Rename ValueIterator to ValueIt in graph maps (#302) but keep ValueIterator as an alias in CrossRefMap (only for reverse compatibility). diff -r acdd0bd75a55 -r d8073df341f6 lemon/maps.h --- a/lemon/maps.h Fri Sep 25 12:12:37 2009 +0200 +++ b/lemon/maps.h Fri Sep 25 12:22:42 2009 +0200 @@ -1907,7 +1907,7 @@ /// and if a key is set to a new value, then stores it in the inverse map. /// The graph items can be accessed by their values either using /// \c InverseMap or \c operator()(), and the values of the map can be - /// accessed with an STL compatible forward iterator (\c ValueIterator). + /// accessed with an STL compatible forward iterator (\c ValueIt). /// /// This map is intended to be used when all associated values are /// different (the map is actually invertable) or there are only a few @@ -1961,22 +1961,22 @@ /// be accessed in the [beginValue, endValue) range. /// They are considered with multiplicity, so each value is /// traversed for each item it is assigned to. - class ValueIterator + class ValueIt : public std::iterator { friend class CrossRefMap; private: - ValueIterator(typename Container::const_iterator _it) + ValueIt(typename Container::const_iterator _it) : it(_it) {} public: /// Constructor - ValueIterator() {} + ValueIt() {} /// \e - ValueIterator& operator++() { ++it; return *this; } + ValueIt& operator++() { ++it; return *this; } /// \e - ValueIterator operator++(int) { - ValueIterator tmp(*this); + ValueIt operator++(int) { + ValueIt tmp(*this); operator++(); return tmp; } @@ -1987,13 +1987,16 @@ const Value* operator->() const { return &(it->first); } /// \e - bool operator==(ValueIterator jt) const { return it == jt.it; } + bool operator==(ValueIt jt) const { return it == jt.it; } /// \e - bool operator!=(ValueIterator jt) const { return it != jt.it; } + bool operator!=(ValueIt jt) const { return it != jt.it; } private: typename Container::const_iterator it; }; + + /// Alias for \c ValueIt + typedef ValueIt ValueIterator; /// \brief Returns an iterator to the first value. /// @@ -2001,8 +2004,8 @@ /// first value of the map. The values of the /// map can be accessed in the [beginValue, endValue) /// range. - ValueIterator beginValue() const { - return ValueIterator(_inv_map.begin()); + ValueIt beginValue() const { + return ValueIt(_inv_map.begin()); } /// \brief Returns an iterator after the last value. @@ -2011,8 +2014,8 @@ /// last value of the map. The values of the /// map can be accessed in the [beginValue, endValue) /// range. - ValueIterator endValue() const { - return ValueIterator(_inv_map.end()); + ValueIt endValue() const { + return ValueIt(_inv_map.end()); } /// \brief Sets the value associated with the given key. @@ -3023,7 +3026,7 @@ /// comparable value for graph items (\c Node, \c Arc or \c Edge). /// For each value it is possible to iterate on the keys mapped to /// the value (\c ItemIt), and the values of the map can be accessed - /// with an STL compatible forward iterator (\c ValueIterator). + /// with an STL compatible forward iterator (\c ValueIt). /// The map stores a linked list for each value, which contains /// the items mapped to the value, and the used values are stored /// in balanced binary tree (\c std::map). @@ -3111,22 +3114,22 @@ /// This iterator is an STL compatible forward /// iterator on the values of the map. The values can /// be accessed in the [beginValue, endValue) range. - class ValueIterator + class ValueIt : public std::iterator { friend class IterableValueMap; private: - ValueIterator(typename std::map::const_iterator _it) + ValueIt(typename std::map::const_iterator _it) : it(_it) {} public: /// Constructor - ValueIterator() {} + ValueIt() {} /// \e - ValueIterator& operator++() { ++it; return *this; } + ValueIt& operator++() { ++it; return *this; } /// \e - ValueIterator operator++(int) { - ValueIterator tmp(*this); + ValueIt operator++(int) { + ValueIt tmp(*this); operator++(); return tmp; } @@ -3137,9 +3140,9 @@ const Value* operator->() const { return &(it->first); } /// \e - bool operator==(ValueIterator jt) const { return it == jt.it; } + bool operator==(ValueIt jt) const { return it == jt.it; } /// \e - bool operator!=(ValueIterator jt) const { return it != jt.it; } + bool operator!=(ValueIt jt) const { return it != jt.it; } private: typename std::map::const_iterator it; @@ -3151,8 +3154,8 @@ /// first value of the map. The values of the /// map can be accessed in the [beginValue, endValue) /// range. - ValueIterator beginValue() const { - return ValueIterator(_first.begin()); + ValueIt beginValue() const { + return ValueIt(_first.begin()); } /// \brief Returns an iterator after the last value. @@ -3161,8 +3164,8 @@ /// last value of the map. The values of the /// map can be accessed in the [beginValue, endValue) /// range. - ValueIterator endValue() const { - return ValueIterator(_first.end()); + ValueIt endValue() const { + return ValueIt(_first.end()); } /// \brief Set operation of the map. @@ -3280,9 +3283,9 @@ class SourceMap { public: - ///\e + /// The key type (the \c Arc type of the digraph). typedef typename GR::Arc Key; - ///\e + /// The value type (the \c Node type of the digraph). typedef typename GR::Node Value; /// \brief Constructor @@ -3321,9 +3324,9 @@ class TargetMap { public: - ///\e + /// The key type (the \c Arc type of the digraph). typedef typename GR::Arc Key; - ///\e + /// The value type (the \c Node type of the digraph). typedef typename GR::Node Value; /// \brief Constructor @@ -3363,8 +3366,10 @@ class ForwardMap { public: + /// The key type (the \c Edge type of the digraph). + typedef typename GR::Edge Key; + /// The value type (the \c Arc type of the digraph). typedef typename GR::Arc Value; - typedef typename GR::Edge Key; /// \brief Constructor /// @@ -3403,8 +3408,10 @@ class BackwardMap { public: + /// The key type (the \c Edge type of the digraph). + typedef typename GR::Edge Key; + /// The value type (the \c Arc type of the digraph). typedef typename GR::Arc Value; - typedef typename GR::Edge Key; /// \brief Constructor /// diff -r acdd0bd75a55 -r d8073df341f6 test/maps_test.cc --- a/test/maps_test.cc Fri Sep 25 12:12:37 2009 +0200 +++ b/test/maps_test.cc Fri Sep 25 12:22:42 2009 +0200 @@ -526,7 +526,6 @@ Graph gr; typedef CrossRefMap CRMap; - typedef CRMap::ValueIterator ValueIt; CRMap map(gr); Node n0 = gr.addNode(); @@ -546,7 +545,7 @@ check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1, "Wrong CrossRefMap::count()"); - ValueIt it = map.beginValue(); + CRMap::ValueIt it = map.beginValue(); check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' && it == map.endValue(), "Wrong value iterator"); @@ -742,10 +741,10 @@ check(static_cast(it) == INVALID, "Wrong value"); } - for (Ivm::ValueIterator vit = map1.beginValue(); + for (Ivm::ValueIt vit = map1.beginValue(); vit != map1.endValue(); ++vit) { check(map1[static_cast(Ivm::ItemIt(map1, *vit))] == *vit, - "Wrong ValueIterator"); + "Wrong ValueIt"); } for (int i = 0; i < num; ++i) {