Improvements for iterable maps (#73)
authorPeter Kovacs <kpeter@inf.elte.hu>
Tue, 21 Jul 2009 22:43:31 +0200
changeset 74171939d63ae77
parent 740 7bda7860e0a8
child 742 8dae88c5943e
child 768 99124ea4f048
Improvements for iterable maps (#73)
lemon/maps.h
test/maps_test.cc
     1.1 --- a/lemon/maps.h	Sat Jun 27 13:07:26 2009 +0200
     1.2 +++ b/lemon/maps.h	Tue Jul 21 22:43:31 2009 +0200
     1.3 @@ -22,16 +22,14 @@
     1.4  #include <iterator>
     1.5  #include <functional>
     1.6  #include <vector>
     1.7 +#include <map>
     1.8  
     1.9  #include <lemon/core.h>
    1.10 -#include <lemon/smart_graph.h>
    1.11  
    1.12  ///\file
    1.13  ///\ingroup maps
    1.14  ///\brief Miscellaneous property maps
    1.15  
    1.16 -#include <map>
    1.17 -
    1.18  namespace lemon {
    1.19  
    1.20    /// \addtogroup maps
    1.21 @@ -1906,10 +1904,12 @@
    1.22    /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap"
    1.23    /// and if a key is set to a new value then store it
    1.24    /// in the inverse map.
    1.25 -  ///
    1.26    /// The values of the map can be accessed
    1.27    /// with stl compatible forward iterator.
    1.28    ///
    1.29 +  /// This type is not reference map, so it cannot be modified with
    1.30 +  /// the subscription operator.
    1.31 +  ///
    1.32    /// \tparam GR The graph type.
    1.33    /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
    1.34    /// \c GR::Edge).
    1.35 @@ -2312,34 +2312,41 @@
    1.36      }
    1.37    };
    1.38  
    1.39 -  /// \brief Dynamic iterable bool map.
    1.40 +  /// \brief Dynamic iterable \c bool map.
    1.41    ///
    1.42 -  /// This class provides a special graph map type which can store for
    1.43 -  /// each graph item(node, arc, edge, etc.) a bool value. For both
    1.44 -  /// the true and the false values it is possible to iterate on the
    1.45 -  /// keys.
    1.46 +  /// This class provides a special graph map type which can store a
    1.47 +  /// \c bool value for graph items (\c Node, \c Arc or \c Edge).
    1.48 +  /// For both \c true and \c false values it is possible to iterate on
    1.49 +  /// the keys.
    1.50    ///
    1.51 -  /// \param GR The graph type.
    1.52 -  /// \param ITEM One of the graph's item types, the key of the map.
    1.53 -  template <typename GR, typename ITEM>
    1.54 +  /// This type is a reference map, so it can be modified with the
    1.55 +  /// subscription operator.
    1.56 +  ///
    1.57 +  /// \tparam GR The graph type.
    1.58 +  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
    1.59 +  /// \c GR::Edge).
    1.60 +  ///
    1.61 +  /// \see IterableIntMap, IterableValueMap
    1.62 +  /// \see CrossRefMap
    1.63 +  template <typename GR, typename K>
    1.64    class IterableBoolMap
    1.65 -    : protected ItemSetTraits<GR, ITEM>::template Map<int>::Type {
    1.66 +    : protected ItemSetTraits<GR, K>::template Map<int>::Type {
    1.67    private:
    1.68      typedef GR Graph;
    1.69  
    1.70 -    typedef typename ItemSetTraits<Graph, ITEM>::ItemIt KeyIt;
    1.71 -    typedef typename ItemSetTraits<GR, ITEM>::template Map<int>::Type Parent;
    1.72 -
    1.73 -    std::vector<ITEM> _array;
    1.74 +    typedef typename ItemSetTraits<GR, K>::ItemIt KeyIt;
    1.75 +    typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Parent;
    1.76 +
    1.77 +    std::vector<K> _array;
    1.78      int _sep;
    1.79  
    1.80    public:
    1.81  
    1.82 -    /// Indicates that the map if reference map.
    1.83 +    /// Indicates that the map is reference map.
    1.84      typedef True ReferenceMapTag;
    1.85  
    1.86      /// The key type
    1.87 -    typedef ITEM Key;
    1.88 +    typedef K Key;
    1.89      /// The value type
    1.90      typedef bool Value;
    1.91      /// The const reference type.
    1.92 @@ -2353,10 +2360,10 @@
    1.93  
    1.94    public:
    1.95  
    1.96 -    /// \brief Refernce to the value of the map.
    1.97 +    /// \brief Reference to the value of the map.
    1.98      ///
    1.99 -    /// This class is similar to the bool type. It can be converted to
   1.100 -    /// bool and it provides the same operators.
   1.101 +    /// This class is similar to the \c bool type. It can be converted to
   1.102 +    /// \c bool and it provides the same operators.
   1.103      class Reference {
   1.104        friend class IterableBoolMap;
   1.105      private:
   1.106 @@ -2454,26 +2461,26 @@
   1.107        _sep = (value ? _array.size() : 0);
   1.108      }
   1.109  
   1.110 -    /// \brief Returns the number of the keys mapped to true.
   1.111 +    /// \brief Returns the number of the keys mapped to \c true.
   1.112      ///
   1.113 -    /// Returns the number of the keys mapped to true.
   1.114 +    /// Returns the number of the keys mapped to \c true.
   1.115      int trueNum() const {
   1.116        return _sep;
   1.117      }
   1.118  
   1.119 -    /// \brief Returns the number of the keys mapped to false.
   1.120 +    /// \brief Returns the number of the keys mapped to \c false.
   1.121      ///
   1.122 -    /// Returns the number of the keys mapped to false.
   1.123 +    /// Returns the number of the keys mapped to \c false.
   1.124      int falseNum() const {
   1.125        return _array.size() - _sep;
   1.126      }
   1.127  
   1.128 -    /// \brief Iterator for the keys mapped to true.
   1.129 +    /// \brief Iterator for the keys mapped to \c true.
   1.130      ///
   1.131 -    /// Iterator for the keys mapped to true. It works
   1.132 -    /// like a graph item iterator in the map, it can be converted
   1.133 +    /// Iterator for the keys mapped to \c true. It works
   1.134 +    /// like a graph item iterator, it can be converted to
   1.135      /// the key type of the map, incremented with \c ++ operator, and
   1.136 -    /// if the iterator leave the last valid key it will be equal to
   1.137 +    /// if the iterator leaves the last valid key, it will be equal to
   1.138      /// \c INVALID.
   1.139      class TrueIt : public Key {
   1.140      public:
   1.141 @@ -2482,38 +2489,37 @@
   1.142        /// \brief Creates an iterator.
   1.143        ///
   1.144        /// Creates an iterator. It iterates on the
   1.145 -      /// keys which mapped to true.
   1.146 -      /// \param map The IterableIntMap
   1.147 +      /// keys mapped to \c true.
   1.148 +      /// \param map The IterableBoolMap.
   1.149        explicit TrueIt(const IterableBoolMap& map)
   1.150          : Parent(map._sep > 0 ? map._array[map._sep - 1] : INVALID),
   1.151            _map(&map) {}
   1.152  
   1.153        /// \brief Invalid constructor \& conversion.
   1.154        ///
   1.155 -      /// This constructor initializes the key to be invalid.
   1.156 +      /// This constructor initializes the iterator to be invalid.
   1.157        /// \sa Invalid for more details.
   1.158        TrueIt(Invalid) : Parent(INVALID), _map(0) {}
   1.159  
   1.160        /// \brief Increment operator.
   1.161        ///
   1.162 -      /// Increment Operator.
   1.163 +      /// Increment operator.
   1.164        TrueIt& operator++() {
   1.165          int pos = _map->position(*this);
   1.166          Parent::operator=(pos > 0 ? _map->_array[pos - 1] : INVALID);
   1.167          return *this;
   1.168        }
   1.169  
   1.170 -
   1.171      private:
   1.172        const IterableBoolMap* _map;
   1.173      };
   1.174  
   1.175 -    /// \brief Iterator for the keys mapped to false.
   1.176 +    /// \brief Iterator for the keys mapped to \c false.
   1.177      ///
   1.178 -    /// Iterator for the keys mapped to false. It works
   1.179 -    /// like a graph item iterator in the map, it can be converted
   1.180 +    /// Iterator for the keys mapped to \c false. It works
   1.181 +    /// like a graph item iterator, it can be converted to
   1.182      /// the key type of the map, incremented with \c ++ operator, and
   1.183 -    /// if the iterator leave the last valid key it will be equal to
   1.184 +    /// if the iterator leaves the last valid key, it will be equal to
   1.185      /// \c INVALID.
   1.186      class FalseIt : public Key {
   1.187      public:
   1.188 @@ -2522,21 +2528,21 @@
   1.189        /// \brief Creates an iterator.
   1.190        ///
   1.191        /// Creates an iterator. It iterates on the
   1.192 -      /// keys which mapped to false.
   1.193 -      /// \param map The IterableIntMap
   1.194 +      /// keys mapped to \c false.
   1.195 +      /// \param map The IterableBoolMap.
   1.196        explicit FalseIt(const IterableBoolMap& map)
   1.197          : Parent(map._sep < int(map._array.size()) ?
   1.198                   map._array.back() : INVALID), _map(&map) {}
   1.199  
   1.200        /// \brief Invalid constructor \& conversion.
   1.201        ///
   1.202 -      /// This constructor initializes the key to be invalid.
   1.203 +      /// This constructor initializes the iterator to be invalid.
   1.204        /// \sa Invalid for more details.
   1.205        FalseIt(Invalid) : Parent(INVALID), _map(0) {}
   1.206  
   1.207        /// \brief Increment operator.
   1.208        ///
   1.209 -      /// Increment Operator.
   1.210 +      /// Increment operator.
   1.211        FalseIt& operator++() {
   1.212          int pos = _map->position(*this);
   1.213          Parent::operator=(pos > _map->_sep ? _map->_array[pos - 1] : INVALID);
   1.214 @@ -2550,20 +2556,20 @@
   1.215      /// \brief Iterator for the keys mapped to a given value.
   1.216      ///
   1.217      /// Iterator for the keys mapped to a given value. It works
   1.218 -    /// like a graph item iterator in the map, it can be converted
   1.219 +    /// like a graph item iterator, it can be converted to
   1.220      /// the key type of the map, incremented with \c ++ operator, and
   1.221 -    /// if the iterator leave the last valid key it will be equal to
   1.222 +    /// if the iterator leaves the last valid key, it will be equal to
   1.223      /// \c INVALID.
   1.224      class ItemIt : public Key {
   1.225      public:
   1.226        typedef Key Parent;
   1.227  
   1.228 -      /// \brief Creates an iterator.
   1.229 +      /// \brief Creates an iterator with a value.
   1.230        ///
   1.231 -      /// Creates an iterator. It iterates on the
   1.232 -      /// keys which mapped to false.
   1.233 -      /// \param map The IterableIntMap
   1.234 -      /// \param value Which elements should be iterated.
   1.235 +      /// Creates an iterator with a value. It iterates on the
   1.236 +      /// keys mapped to the given value.
   1.237 +      /// \param map The IterableBoolMap.
   1.238 +      /// \param value The value.
   1.239        ItemIt(const IterableBoolMap& map, bool value)
   1.240          : Parent(value ? 
   1.241                   (map._sep > 0 ?
   1.242 @@ -2573,13 +2579,13 @@
   1.243  
   1.244        /// \brief Invalid constructor \& conversion.
   1.245        ///
   1.246 -      /// This constructor initializes the key to be invalid.
   1.247 +      /// This constructor initializes the iterator to be invalid.
   1.248        /// \sa Invalid for more details.
   1.249        ItemIt(Invalid) : Parent(INVALID), _map(0) {}
   1.250  
   1.251        /// \brief Increment operator.
   1.252        ///
   1.253 -      /// Increment Operator.
   1.254 +      /// Increment operator.
   1.255        ItemIt& operator++() {
   1.256          int pos = _map->position(*this);
   1.257          int _sep = pos >= _map->_sep ? _map->_sep : 0;
   1.258 @@ -2673,30 +2679,35 @@
   1.259      };
   1.260    }
   1.261  
   1.262 -  ///\ingroup graph_maps
   1.263 -  ///
   1.264    /// \brief Dynamic iterable integer map.
   1.265    ///
   1.266 -  /// This class provides a special graph map type which can store
   1.267 -  /// for each graph item(node, edge, etc.) an integer value. For each
   1.268 -  /// non negative value it is possible to iterate on the keys which
   1.269 -  /// mapped to the given value.
   1.270 +  /// This class provides a special graph map type which can store an
   1.271 +  /// integer value for graph items (\c Node, \c Arc or \c Edge).
   1.272 +  /// For each non-negative value it is possible to iterate on the keys
   1.273 +  /// mapped to the value.
   1.274    ///
   1.275 -  /// \note The size of the data structure depends on the highest
   1.276 +  /// This type is a reference map, so it can be modified with the
   1.277 +  /// subscription operator.
   1.278 +  ///
   1.279 +  /// \note The size of the data structure depends on the largest
   1.280    /// value in the map.
   1.281    ///
   1.282 -  /// \param GR The graph type.
   1.283 -  /// \param ITEM One of the graph's item type, the key of the map.
   1.284 -  template <typename GR, typename ITEM>
   1.285 +  /// \tparam GR The graph type.
   1.286 +  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
   1.287 +  /// \c GR::Edge).
   1.288 +  ///
   1.289 +  /// \see IterableBoolMap, IterableValueMap
   1.290 +  /// \see CrossRefMap
   1.291 +  template <typename GR, typename K>
   1.292    class IterableIntMap
   1.293 -    : protected ItemSetTraits<GR, ITEM>::
   1.294 -        template Map<_maps_bits::IterableIntMapNode<ITEM> >::Type {
   1.295 +    : protected ItemSetTraits<GR, K>::
   1.296 +        template Map<_maps_bits::IterableIntMapNode<K> >::Type {
   1.297    public:
   1.298 -    typedef typename ItemSetTraits<GR, ITEM>::
   1.299 -      template Map<_maps_bits::IterableIntMapNode<ITEM> >::Type Parent;
   1.300 +    typedef typename ItemSetTraits<GR, K>::
   1.301 +      template Map<_maps_bits::IterableIntMapNode<K> >::Type Parent;
   1.302  
   1.303      /// The key type
   1.304 -    typedef ITEM Key;
   1.305 +    typedef K Key;
   1.306      /// The value type
   1.307      typedef int Value;
   1.308      /// The graph type
   1.309 @@ -2704,7 +2715,7 @@
   1.310  
   1.311      /// \brief Constructor of the map.
   1.312      ///
   1.313 -    /// Constructor of the map. It set all values to -1.
   1.314 +    /// Constructor of the map. It sets all values to -1.
   1.315      explicit IterableIntMap(const Graph& graph)
   1.316        : Parent(graph) {}
   1.317  
   1.318 @@ -2712,7 +2723,7 @@
   1.319      ///
   1.320      /// Constructor of the map with a given value.
   1.321      explicit IterableIntMap(const Graph& graph, int value)
   1.322 -      : Parent(graph, _maps_bits::IterableIntMapNode<ITEM>(value)) {
   1.323 +      : Parent(graph, _maps_bits::IterableIntMapNode<K>(value)) {
   1.324        if (value >= 0) {
   1.325          for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
   1.326            lace(it);
   1.327 @@ -2754,13 +2765,13 @@
   1.328  
   1.329    public:
   1.330  
   1.331 -    /// Indicates that the map if reference map.
   1.332 +    /// Indicates that the map is reference map.
   1.333      typedef True ReferenceMapTag;
   1.334  
   1.335 -    /// \brief Refernce to the value of the map.
   1.336 +    /// \brief Reference to the value of the map.
   1.337      ///
   1.338 -    /// This class is similar to the int type. It can
   1.339 -    /// be converted to int and it has the same operators.
   1.340 +    /// This class is similar to the \c int type. It can
   1.341 +    /// be converted to \c int and it has the same operators.
   1.342      class Reference {
   1.343        friend class IterableIntMap;
   1.344      private:
   1.345 @@ -2881,26 +2892,26 @@
   1.346      /// \brief Iterator for the keys with the same value.
   1.347      ///
   1.348      /// Iterator for the keys with the same value. It works
   1.349 -    /// like a graph item iterator in the map, it can be converted
   1.350 +    /// like a graph item iterator, it can be converted to
   1.351      /// the item type of the map, incremented with \c ++ operator, and
   1.352 -    /// if the iterator leave the last valid item it will be equal to
   1.353 +    /// if the iterator leaves the last valid item, it will be equal to
   1.354      /// \c INVALID.
   1.355 -    class ItemIt : public ITEM {
   1.356 +    class ItemIt : public Key {
   1.357      public:
   1.358 -      typedef ITEM Parent;
   1.359 +      typedef Key Parent;
   1.360  
   1.361        /// \brief Invalid constructor \& conversion.
   1.362        ///
   1.363 -      /// This constructor initializes the item to be invalid.
   1.364 +      /// This constructor initializes the iterator to be invalid.
   1.365        /// \sa Invalid for more details.
   1.366        ItemIt(Invalid) : Parent(INVALID), _map(0) {}
   1.367  
   1.368        /// \brief Creates an iterator with a value.
   1.369        ///
   1.370        /// Creates an iterator with a value. It iterates on the
   1.371 -      /// keys which have the given value.
   1.372 -      /// \param map The IterableIntMap
   1.373 -      /// \param value The value
   1.374 +      /// keys mapped to the given value.
   1.375 +      /// \param map The IterableIntMap.
   1.376 +      /// \param value The value.
   1.377        ItemIt(const IterableIntMap& map, int value) : _map(&map) {
   1.378          if (value < 0 || value >= int(_map->_first.size())) {
   1.379            Parent::operator=(INVALID);
   1.380 @@ -2911,14 +2922,13 @@
   1.381  
   1.382        /// \brief Increment operator.
   1.383        ///
   1.384 -      /// Increment Operator.
   1.385 +      /// Increment operator.
   1.386        ItemIt& operator++() {
   1.387          Parent::operator=(_map->IterableIntMap::Parent::
   1.388                            operator[](static_cast<Parent&>(*this)).next);
   1.389          return *this;
   1.390        }
   1.391  
   1.392 -
   1.393      private:
   1.394        const IterableIntMap* _map;
   1.395      };
   1.396 @@ -2943,7 +2953,7 @@
   1.397      }
   1.398  
   1.399    private:
   1.400 -    std::vector<ITEM> _first;
   1.401 +    std::vector<Key> _first;
   1.402    };
   1.403  
   1.404    namespace _maps_bits {
   1.405 @@ -2955,49 +2965,52 @@
   1.406      };
   1.407    }
   1.408  
   1.409 -  ///\ingroup graph_maps
   1.410 -  ///
   1.411    /// \brief Dynamic iterable map for comparable values.
   1.412    ///
   1.413 -  /// This class provides a special graph map type which can store
   1.414 -  /// for each graph item(node, edge, etc.) a value. For each
   1.415 -  /// value it is possible to iterate on the keys which mapped to the
   1.416 -  /// given value. The type stores for each value a linked list with
   1.417 +  /// This class provides a special graph map type which can store an
   1.418 +  /// comparable value for graph items (\c Node, \c Arc or \c Edge).
   1.419 +  /// For each value it is possible to iterate on the keys mapped to
   1.420 +  /// the value.
   1.421 +  ///
   1.422 +  /// The map stores for each value a linked list with
   1.423    /// the items which mapped to the value, and the values are stored
   1.424    /// in balanced binary tree. The values of the map can be accessed
   1.425    /// with stl compatible forward iterator.
   1.426    ///
   1.427 -  /// This type is not reference map so it cannot be modified with
   1.428 +  /// This type is not reference map, so it cannot be modified with
   1.429    /// the subscription operator.
   1.430    ///
   1.431 -  /// \see InvertableMap
   1.432 +  /// \tparam GR The graph type.
   1.433 +  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
   1.434 +  /// \c GR::Edge).
   1.435 +  /// \tparam V The value type of the map. It can be any comparable
   1.436 +  /// value type.
   1.437    ///
   1.438 -  /// \param GR The graph type.
   1.439 -  /// \param ITEM One of the graph's item type, the key of the map.
   1.440 -  /// \param VAL Any comparable value type.
   1.441 -  template <typename GR, typename ITEM, typename VAL>
   1.442 +  /// \see IterableBoolMap, IterableIntMap
   1.443 +  /// \see CrossRefMap
   1.444 +  template <typename GR, typename K, typename V>
   1.445    class IterableValueMap
   1.446 -    : protected ItemSetTraits<GR, ITEM>::
   1.447 -        template Map<_maps_bits::IterableValueMapNode<ITEM, VAL> >::Type {
   1.448 +    : protected ItemSetTraits<GR, K>::
   1.449 +        template Map<_maps_bits::IterableValueMapNode<K, V> >::Type {
   1.450    public:
   1.451 -    typedef typename ItemSetTraits<GR, ITEM>::
   1.452 -      template Map<_maps_bits::IterableValueMapNode<ITEM, VAL> >::Type Parent;
   1.453 +    typedef typename ItemSetTraits<GR, K>::
   1.454 +      template Map<_maps_bits::IterableValueMapNode<K, V> >::Type Parent;
   1.455  
   1.456      /// The key type
   1.457 -    typedef ITEM Key;
   1.458 +    typedef K Key;
   1.459      /// The value type
   1.460 -    typedef VAL Value;
   1.461 +    typedef V Value;
   1.462      /// The graph type
   1.463      typedef GR Graph;
   1.464  
   1.465    public:
   1.466  
   1.467 -    /// \brief Constructor of the Map with a given value.
   1.468 +    /// \brief Constructor of the map with a given value.
   1.469      ///
   1.470 -    /// Constructor of the Map with a given value.
   1.471 +    /// Constructor of the map with a given value.
   1.472      explicit IterableValueMap(const Graph& graph,
   1.473                                const Value& value = Value())
   1.474 -      : Parent(graph, _maps_bits::IterableValueMapNode<ITEM, VAL>(value)) {
   1.475 +      : Parent(graph, _maps_bits::IterableValueMapNode<K, V>(value)) {
   1.476        for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
   1.477          lace(it);
   1.478        }
   1.479 @@ -3026,9 +3039,6 @@
   1.480        typename std::map<Value, Key>::iterator it = _first.find(node.value);
   1.481        if (it == _first.end()) {
   1.482          node.prev = node.next = INVALID;
   1.483 -        if (node.next != INVALID) {
   1.484 -          Parent::operator[](node.next).prev = key;
   1.485 -        }
   1.486          _first.insert(std::make_pair(node.value, key));
   1.487        } else {
   1.488          node.prev = INVALID;
   1.489 @@ -3046,8 +3056,7 @@
   1.490      ///
   1.491      /// This iterator is an stl compatible forward
   1.492      /// iterator on the values of the map. The values can
   1.493 -    /// be accessed in the [beginValue, endValue) range.
   1.494 -    ///
   1.495 +    /// be accessed in the <tt>[beginValue, endValue)</tt> range.
   1.496      class ValueIterator
   1.497        : public std::iterator<std::forward_iterator_tag, Value> {
   1.498        friend class IterableValueMap;
   1.499 @@ -3079,7 +3088,7 @@
   1.500      ///
   1.501      /// Returns an stl compatible iterator to the
   1.502      /// first value of the map. The values of the
   1.503 -    /// map can be accessed in the [beginValue, endValue)
   1.504 +    /// map can be accessed in the <tt>[beginValue, endValue)</tt>
   1.505      /// range.
   1.506      ValueIterator beginValue() const {
   1.507        return ValueIterator(_first.begin());
   1.508 @@ -3089,7 +3098,7 @@
   1.509      ///
   1.510      /// Returns an stl compatible iterator after the
   1.511      /// last value of the map. The values of the
   1.512 -    /// map can be accessed in the [beginValue, endValue)
   1.513 +    /// map can be accessed in the <tt>[beginValue, endValue)</tt>
   1.514      /// range.
   1.515      ValueIterator endValue() const {
   1.516        return ValueIterator(_first.end());
   1.517 @@ -3114,17 +3123,17 @@
   1.518      /// \brief Iterator for the keys with the same value.
   1.519      ///
   1.520      /// Iterator for the keys with the same value. It works
   1.521 -    /// like a graph item iterator in the map, it can be converted
   1.522 +    /// like a graph item iterator, it can be converted to
   1.523      /// the item type of the map, incremented with \c ++ operator, and
   1.524 -    /// if the iterator leave the last valid item it will be equal to
   1.525 +    /// if the iterator leaves the last valid item, it will be equal to
   1.526      /// \c INVALID.
   1.527 -    class ItemIt : public ITEM {
   1.528 +    class ItemIt : public Key {
   1.529      public:
   1.530 -      typedef ITEM Parent;
   1.531 +      typedef Key Parent;
   1.532  
   1.533        /// \brief Invalid constructor \& conversion.
   1.534        ///
   1.535 -      /// This constructor initializes the item to be invalid.
   1.536 +      /// This constructor initializes the iterator to be invalid.
   1.537        /// \sa Invalid for more details.
   1.538        ItemIt(Invalid) : Parent(INVALID), _map(0) {}
   1.539  
     2.1 --- a/test/maps_test.cc	Sat Jun 27 13:07:26 2009 +0200
     2.2 +++ b/test/maps_test.cc	Tue Jul 21 22:43:31 2009 +0200
     2.3 @@ -22,6 +22,7 @@
     2.4  #include <lemon/concept_check.h>
     2.5  #include <lemon/concepts/maps.h>
     2.6  #include <lemon/maps.h>
     2.7 +#include <lemon/smart_graph.h>
     2.8  
     2.9  #include "test_tools.h"
    2.10  
    2.11 @@ -355,7 +356,7 @@
    2.12      typedef SmartGraph::Node Item;
    2.13  
    2.14      typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm;
    2.15 -    checkConcept<ReadWriteMap<Item, int>, Ibm>();
    2.16 +    checkConcept<ReferenceMap<Item, bool, bool&, const bool&>, Ibm>();
    2.17  
    2.18      const int num = 10;
    2.19      Graph g;
    2.20 @@ -436,7 +437,7 @@
    2.21      typedef SmartGraph::Node Item;
    2.22      typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim;
    2.23  
    2.24 -    checkConcept<ReadWriteMap<Item, int>, Iim>();
    2.25 +    checkConcept<ReferenceMap<Item, int, int&, const int&>, Iim>();
    2.26  
    2.27      const int num = 10;
    2.28      Graph g;
    2.29 @@ -467,13 +468,13 @@
    2.30  
    2.31      int n = 0;
    2.32      for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) {
    2.33 -      check(map1[static_cast<Item>(it)] == 0, "Wrong Value");
    2.34 +      check(map1[static_cast<Item>(it)] == 0, "Wrong value");
    2.35        ++n;
    2.36      }
    2.37      check(n == (num + 1) / 2, "Wrong number");
    2.38  
    2.39      for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) {
    2.40 -      check(map1[static_cast<Item>(it)] == 1, "Wrong Value");
    2.41 +      check(map1[static_cast<Item>(it)] == 1, "Wrong value");
    2.42        ++n;
    2.43      }
    2.44      check(n == num, "Wrong number");
    2.45 @@ -524,13 +525,13 @@
    2.46  
    2.47      int n = 0;
    2.48      for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) {
    2.49 -      check(map1[static_cast<Item>(it)] == 0.0, "Wrong Value");
    2.50 +      check(map1[static_cast<Item>(it)] == 0.0, "Wrong value");
    2.51        ++n;
    2.52      }
    2.53      check(n == (num + 1) / 2, "Wrong number");
    2.54  
    2.55      for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) {
    2.56 -      check(map1[static_cast<Item>(it)] == 1.0, "Wrong Value");
    2.57 +      check(map1[static_cast<Item>(it)] == 1.0, "Wrong value");
    2.58        ++n;
    2.59      }
    2.60      check(n == num, "Wrong number");