Rename ValueIterator to ValueIt in graph maps (#302)
authorPeter Kovacs <kpeter@inf.elte.hu>
Fri, 25 Sep 2009 12:22:42 +0200
changeset 724d8073df341f6
parent 723 acdd0bd75a55
child 725 11404088d1a5
Rename ValueIterator to ValueIt in graph maps (#302)
but keep ValueIterator as an alias in CrossRefMap
(only for reverse compatibility).
lemon/maps.h
test/maps_test.cc
     1.1 --- a/lemon/maps.h	Fri Sep 25 12:12:37 2009 +0200
     1.2 +++ b/lemon/maps.h	Fri Sep 25 12:22:42 2009 +0200
     1.3 @@ -1907,7 +1907,7 @@
     1.4    /// and if a key is set to a new value, then stores it in the inverse map.
     1.5    /// The graph items can be accessed by their values either using
     1.6    /// \c InverseMap or \c operator()(), and the values of the map can be
     1.7 -  /// accessed with an STL compatible forward iterator (\c ValueIterator).
     1.8 +  /// accessed with an STL compatible forward iterator (\c ValueIt).
     1.9    /// 
    1.10    /// This map is intended to be used when all associated values are
    1.11    /// different (the map is actually invertable) or there are only a few
    1.12 @@ -1961,22 +1961,22 @@
    1.13      /// be accessed in the <tt>[beginValue, endValue)</tt> range.
    1.14      /// They are considered with multiplicity, so each value is
    1.15      /// traversed for each item it is assigned to.
    1.16 -    class ValueIterator
    1.17 +    class ValueIt
    1.18        : public std::iterator<std::forward_iterator_tag, Value> {
    1.19        friend class CrossRefMap;
    1.20      private:
    1.21 -      ValueIterator(typename Container::const_iterator _it)
    1.22 +      ValueIt(typename Container::const_iterator _it)
    1.23          : it(_it) {}
    1.24      public:
    1.25  
    1.26        /// Constructor
    1.27 -      ValueIterator() {}
    1.28 +      ValueIt() {}
    1.29  
    1.30        /// \e
    1.31 -      ValueIterator& operator++() { ++it; return *this; }
    1.32 +      ValueIt& operator++() { ++it; return *this; }
    1.33        /// \e
    1.34 -      ValueIterator operator++(int) {
    1.35 -        ValueIterator tmp(*this);
    1.36 +      ValueIt operator++(int) {
    1.37 +        ValueIt tmp(*this);
    1.38          operator++();
    1.39          return tmp;
    1.40        }
    1.41 @@ -1987,13 +1987,16 @@
    1.42        const Value* operator->() const { return &(it->first); }
    1.43  
    1.44        /// \e
    1.45 -      bool operator==(ValueIterator jt) const { return it == jt.it; }
    1.46 +      bool operator==(ValueIt jt) const { return it == jt.it; }
    1.47        /// \e
    1.48 -      bool operator!=(ValueIterator jt) const { return it != jt.it; }
    1.49 +      bool operator!=(ValueIt jt) const { return it != jt.it; }
    1.50  
    1.51      private:
    1.52        typename Container::const_iterator it;
    1.53      };
    1.54 +    
    1.55 +    /// Alias for \c ValueIt
    1.56 +    typedef ValueIt ValueIterator;
    1.57  
    1.58      /// \brief Returns an iterator to the first value.
    1.59      ///
    1.60 @@ -2001,8 +2004,8 @@
    1.61      /// first value of the map. The values of the
    1.62      /// map can be accessed in the <tt>[beginValue, endValue)</tt>
    1.63      /// range.
    1.64 -    ValueIterator beginValue() const {
    1.65 -      return ValueIterator(_inv_map.begin());
    1.66 +    ValueIt beginValue() const {
    1.67 +      return ValueIt(_inv_map.begin());
    1.68      }
    1.69  
    1.70      /// \brief Returns an iterator after the last value.
    1.71 @@ -2011,8 +2014,8 @@
    1.72      /// last value of the map. The values of the
    1.73      /// map can be accessed in the <tt>[beginValue, endValue)</tt>
    1.74      /// range.
    1.75 -    ValueIterator endValue() const {
    1.76 -      return ValueIterator(_inv_map.end());
    1.77 +    ValueIt endValue() const {
    1.78 +      return ValueIt(_inv_map.end());
    1.79      }
    1.80  
    1.81      /// \brief Sets the value associated with the given key.
    1.82 @@ -3023,7 +3026,7 @@
    1.83    /// comparable value for graph items (\c Node, \c Arc or \c Edge).
    1.84    /// For each value it is possible to iterate on the keys mapped to
    1.85    /// the value (\c ItemIt), and the values of the map can be accessed
    1.86 -  /// with an STL compatible forward iterator (\c ValueIterator).
    1.87 +  /// with an STL compatible forward iterator (\c ValueIt).
    1.88    /// The map stores a linked list for each value, which contains
    1.89    /// the items mapped to the value, and the used values are stored
    1.90    /// in balanced binary tree (\c std::map).
    1.91 @@ -3111,22 +3114,22 @@
    1.92      /// This iterator is an STL compatible forward
    1.93      /// iterator on the values of the map. The values can
    1.94      /// be accessed in the <tt>[beginValue, endValue)</tt> range.
    1.95 -    class ValueIterator
    1.96 +    class ValueIt
    1.97        : public std::iterator<std::forward_iterator_tag, Value> {
    1.98        friend class IterableValueMap;
    1.99      private:
   1.100 -      ValueIterator(typename std::map<Value, Key>::const_iterator _it)
   1.101 +      ValueIt(typename std::map<Value, Key>::const_iterator _it)
   1.102          : it(_it) {}
   1.103      public:
   1.104  
   1.105        /// Constructor
   1.106 -      ValueIterator() {}
   1.107 +      ValueIt() {}
   1.108  
   1.109        /// \e
   1.110 -      ValueIterator& operator++() { ++it; return *this; }
   1.111 +      ValueIt& operator++() { ++it; return *this; }
   1.112        /// \e
   1.113 -      ValueIterator operator++(int) {
   1.114 -        ValueIterator tmp(*this);
   1.115 +      ValueIt operator++(int) {
   1.116 +        ValueIt tmp(*this);
   1.117          operator++();
   1.118          return tmp;
   1.119        }
   1.120 @@ -3137,9 +3140,9 @@
   1.121        const Value* operator->() const { return &(it->first); }
   1.122  
   1.123        /// \e
   1.124 -      bool operator==(ValueIterator jt) const { return it == jt.it; }
   1.125 +      bool operator==(ValueIt jt) const { return it == jt.it; }
   1.126        /// \e
   1.127 -      bool operator!=(ValueIterator jt) const { return it != jt.it; }
   1.128 +      bool operator!=(ValueIt jt) const { return it != jt.it; }
   1.129  
   1.130      private:
   1.131        typename std::map<Value, Key>::const_iterator it;
   1.132 @@ -3151,8 +3154,8 @@
   1.133      /// first value of the map. The values of the
   1.134      /// map can be accessed in the <tt>[beginValue, endValue)</tt>
   1.135      /// range.
   1.136 -    ValueIterator beginValue() const {
   1.137 -      return ValueIterator(_first.begin());
   1.138 +    ValueIt beginValue() const {
   1.139 +      return ValueIt(_first.begin());
   1.140      }
   1.141  
   1.142      /// \brief Returns an iterator after the last value.
   1.143 @@ -3161,8 +3164,8 @@
   1.144      /// last value of the map. The values of the
   1.145      /// map can be accessed in the <tt>[beginValue, endValue)</tt>
   1.146      /// range.
   1.147 -    ValueIterator endValue() const {
   1.148 -      return ValueIterator(_first.end());
   1.149 +    ValueIt endValue() const {
   1.150 +      return ValueIt(_first.end());
   1.151      }
   1.152  
   1.153      /// \brief Set operation of the map.
   1.154 @@ -3280,9 +3283,9 @@
   1.155    class SourceMap {
   1.156    public:
   1.157  
   1.158 -    ///\e
   1.159 +    /// The key type (the \c Arc type of the digraph).
   1.160      typedef typename GR::Arc Key;
   1.161 -    ///\e
   1.162 +    /// The value type (the \c Node type of the digraph).
   1.163      typedef typename GR::Node Value;
   1.164  
   1.165      /// \brief Constructor
   1.166 @@ -3321,9 +3324,9 @@
   1.167    class TargetMap {
   1.168    public:
   1.169  
   1.170 -    ///\e
   1.171 +    /// The key type (the \c Arc type of the digraph).
   1.172      typedef typename GR::Arc Key;
   1.173 -    ///\e
   1.174 +    /// The value type (the \c Node type of the digraph).
   1.175      typedef typename GR::Node Value;
   1.176  
   1.177      /// \brief Constructor
   1.178 @@ -3363,8 +3366,10 @@
   1.179    class ForwardMap {
   1.180    public:
   1.181  
   1.182 +    /// The key type (the \c Edge type of the digraph).
   1.183 +    typedef typename GR::Edge Key;
   1.184 +    /// The value type (the \c Arc type of the digraph).
   1.185      typedef typename GR::Arc Value;
   1.186 -    typedef typename GR::Edge Key;
   1.187  
   1.188      /// \brief Constructor
   1.189      ///
   1.190 @@ -3403,8 +3408,10 @@
   1.191    class BackwardMap {
   1.192    public:
   1.193  
   1.194 +    /// The key type (the \c Edge type of the digraph).
   1.195 +    typedef typename GR::Edge Key;
   1.196 +    /// The value type (the \c Arc type of the digraph).
   1.197      typedef typename GR::Arc Value;
   1.198 -    typedef typename GR::Edge Key;
   1.199  
   1.200      /// \brief Constructor
   1.201      ///
     2.1 --- a/test/maps_test.cc	Fri Sep 25 12:12:37 2009 +0200
     2.2 +++ b/test/maps_test.cc	Fri Sep 25 12:22:42 2009 +0200
     2.3 @@ -526,7 +526,6 @@
     2.4      
     2.5      Graph gr;
     2.6      typedef CrossRefMap<Graph, Node, char> CRMap;
     2.7 -    typedef CRMap::ValueIterator ValueIt;
     2.8      CRMap map(gr);
     2.9      
    2.10      Node n0 = gr.addNode();
    2.11 @@ -546,7 +545,7 @@
    2.12      check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1,
    2.13            "Wrong CrossRefMap::count()");
    2.14      
    2.15 -    ValueIt it = map.beginValue();
    2.16 +    CRMap::ValueIt it = map.beginValue();
    2.17      check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
    2.18            it == map.endValue(), "Wrong value iterator");
    2.19      
    2.20 @@ -742,10 +741,10 @@
    2.21        check(static_cast<Item>(it) == INVALID, "Wrong value");
    2.22      }
    2.23  
    2.24 -    for (Ivm::ValueIterator vit = map1.beginValue();
    2.25 +    for (Ivm::ValueIt vit = map1.beginValue();
    2.26           vit != map1.endValue(); ++vit) {
    2.27        check(map1[static_cast<Item>(Ivm::ItemIt(map1, *vit))] == *vit,
    2.28 -            "Wrong ValueIterator");
    2.29 +            "Wrong ValueIt");
    2.30      }
    2.31  
    2.32      for (int i = 0; i < num; ++i) {