Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 740)
+++ lemon/maps.h	(revision 741)
@@ -23,13 +23,11 @@
 #include <functional>
 #include <vector>
+#include <map>
 
 #include <lemon/core.h>
-#include <lemon/smart_graph.h>
 
 ///\file
 ///\ingroup maps
 ///\brief Miscellaneous property maps
-
-#include <map>
 
 namespace lemon {
@@ -1907,7 +1905,9 @@
   /// and if a key is set to a new value then store it
   /// in the inverse map.
-  ///
   /// The values of the map can be accessed
   /// with stl compatible forward iterator.
+  ///
+  /// This type is not reference map, so it cannot be modified with
+  /// the subscription operator.
   ///
   /// \tparam GR The graph type.
@@ -2313,32 +2313,39 @@
   };
 
-  /// \brief Dynamic iterable bool map.
-  ///
-  /// This class provides a special graph map type which can store for
-  /// each graph item(node, arc, edge, etc.) a bool value. For both
-  /// the true and the false values it is possible to iterate on the
-  /// keys.
-  ///
-  /// \param GR The graph type.
-  /// \param ITEM One of the graph's item types, the key of the map.
-  template <typename GR, typename ITEM>
+  /// \brief Dynamic iterable \c bool map.
+  ///
+  /// This class provides a special graph map type which can store a
+  /// \c bool value for graph items (\c Node, \c Arc or \c Edge).
+  /// For both \c true and \c false values it is possible to iterate on
+  /// the keys.
+  ///
+  /// This type is a reference map, so it can be modified with the
+  /// subscription operator.
+  ///
+  /// \tparam GR The graph type.
+  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
+  /// \c GR::Edge).
+  ///
+  /// \see IterableIntMap, IterableValueMap
+  /// \see CrossRefMap
+  template <typename GR, typename K>
   class IterableBoolMap
-    : protected ItemSetTraits<GR, ITEM>::template Map<int>::Type {
+    : protected ItemSetTraits<GR, K>::template Map<int>::Type {
   private:
     typedef GR Graph;
 
-    typedef typename ItemSetTraits<Graph, ITEM>::ItemIt KeyIt;
-    typedef typename ItemSetTraits<GR, ITEM>::template Map<int>::Type Parent;
-
-    std::vector<ITEM> _array;
+    typedef typename ItemSetTraits<GR, K>::ItemIt KeyIt;
+    typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Parent;
+
+    std::vector<K> _array;
     int _sep;
 
   public:
 
-    /// Indicates that the map if reference map.
+    /// Indicates that the map is reference map.
     typedef True ReferenceMapTag;
 
     /// The key type
-    typedef ITEM Key;
+    typedef K Key;
     /// The value type
     typedef bool Value;
@@ -2354,8 +2361,8 @@
   public:
 
-    /// \brief Refernce to the value of the map.
-    ///
-    /// This class is similar to the bool type. It can be converted to
-    /// bool and it provides the same operators.
+    /// \brief Reference to the value of the map.
+    ///
+    /// This class is similar to the \c bool type. It can be converted to
+    /// \c bool and it provides the same operators.
     class Reference {
       friend class IterableBoolMap;
@@ -2455,24 +2462,24 @@
     }
 
-    /// \brief Returns the number of the keys mapped to true.
-    ///
-    /// Returns the number of the keys mapped to true.
+    /// \brief Returns the number of the keys mapped to \c true.
+    ///
+    /// Returns the number of the keys mapped to \c true.
     int trueNum() const {
       return _sep;
     }
 
-    /// \brief Returns the number of the keys mapped to false.
-    ///
-    /// Returns the number of the keys mapped to false.
+    /// \brief Returns the number of the keys mapped to \c false.
+    ///
+    /// Returns the number of the keys mapped to \c false.
     int falseNum() const {
       return _array.size() - _sep;
     }
 
-    /// \brief Iterator for the keys mapped to true.
-    ///
-    /// Iterator for the keys mapped to true. It works
-    /// like a graph item iterator in the map, it can be converted
+    /// \brief Iterator for the keys mapped to \c true.
+    ///
+    /// Iterator for the keys mapped to \c true. It works
+    /// like a graph item iterator, it can be converted to
     /// the key type of the map, incremented with \c ++ operator, and
-    /// if the iterator leave the last valid key it will be equal to
+    /// if the iterator leaves the last valid key, it will be equal to
     /// \c INVALID.
     class TrueIt : public Key {
@@ -2483,6 +2490,6 @@
       ///
       /// Creates an iterator. It iterates on the
-      /// keys which mapped to true.
-      /// \param map The IterableIntMap
+      /// keys mapped to \c true.
+      /// \param map The IterableBoolMap.
       explicit TrueIt(const IterableBoolMap& map)
         : Parent(map._sep > 0 ? map._array[map._sep - 1] : INVALID),
@@ -2491,5 +2498,5 @@
       /// \brief Invalid constructor \& conversion.
       ///
-      /// This constructor initializes the key to be invalid.
+      /// This constructor initializes the iterator to be invalid.
       /// \sa Invalid for more details.
       TrueIt(Invalid) : Parent(INVALID), _map(0) {}
@@ -2497,5 +2504,5 @@
       /// \brief Increment operator.
       ///
-      /// Increment Operator.
+      /// Increment operator.
       TrueIt& operator++() {
         int pos = _map->position(*this);
@@ -2504,15 +2511,14 @@
       }
 
-
     private:
       const IterableBoolMap* _map;
     };
 
-    /// \brief Iterator for the keys mapped to false.
-    ///
-    /// Iterator for the keys mapped to false. It works
-    /// like a graph item iterator in the map, it can be converted
+    /// \brief Iterator for the keys mapped to \c false.
+    ///
+    /// Iterator for the keys mapped to \c false. It works
+    /// like a graph item iterator, it can be converted to
     /// the key type of the map, incremented with \c ++ operator, and
-    /// if the iterator leave the last valid key it will be equal to
+    /// if the iterator leaves the last valid key, it will be equal to
     /// \c INVALID.
     class FalseIt : public Key {
@@ -2523,6 +2529,6 @@
       ///
       /// Creates an iterator. It iterates on the
-      /// keys which mapped to false.
-      /// \param map The IterableIntMap
+      /// keys mapped to \c false.
+      /// \param map The IterableBoolMap.
       explicit FalseIt(const IterableBoolMap& map)
         : Parent(map._sep < int(map._array.size()) ?
@@ -2531,5 +2537,5 @@
       /// \brief Invalid constructor \& conversion.
       ///
-      /// This constructor initializes the key to be invalid.
+      /// This constructor initializes the iterator to be invalid.
       /// \sa Invalid for more details.
       FalseIt(Invalid) : Parent(INVALID), _map(0) {}
@@ -2537,5 +2543,5 @@
       /// \brief Increment operator.
       ///
-      /// Increment Operator.
+      /// Increment operator.
       FalseIt& operator++() {
         int pos = _map->position(*this);
@@ -2551,7 +2557,7 @@
     ///
     /// Iterator for the keys mapped to a given value. It works
-    /// like a graph item iterator in the map, it can be converted
+    /// like a graph item iterator, it can be converted to
     /// the key type of the map, incremented with \c ++ operator, and
-    /// if the iterator leave the last valid key it will be equal to
+    /// if the iterator leaves the last valid key, it will be equal to
     /// \c INVALID.
     class ItemIt : public Key {
@@ -2559,10 +2565,10 @@
       typedef Key Parent;
 
-      /// \brief Creates an iterator.
+      /// \brief Creates an iterator with a value.
       ///
-      /// Creates an iterator. It iterates on the
-      /// keys which mapped to false.
-      /// \param map The IterableIntMap
-      /// \param value Which elements should be iterated.
+      /// Creates an iterator with a value. It iterates on the
+      /// keys mapped to the given value.
+      /// \param map The IterableBoolMap.
+      /// \param value The value.
       ItemIt(const IterableBoolMap& map, bool value)
         : Parent(value ? 
@@ -2574,5 +2580,5 @@
       /// \brief Invalid constructor \& conversion.
       ///
-      /// This constructor initializes the key to be invalid.
+      /// This constructor initializes the iterator to be invalid.
       /// \sa Invalid for more details.
       ItemIt(Invalid) : Parent(INVALID), _map(0) {}
@@ -2580,5 +2586,5 @@
       /// \brief Increment operator.
       ///
-      /// Increment Operator.
+      /// Increment operator.
       ItemIt& operator++() {
         int pos = _map->position(*this);
@@ -2674,28 +2680,33 @@
   }
 
-  ///\ingroup graph_maps
-  ///
   /// \brief Dynamic iterable integer map.
   ///
-  /// This class provides a special graph map type which can store
-  /// for each graph item(node, edge, etc.) an integer value. For each
-  /// non negative value it is possible to iterate on the keys which
-  /// mapped to the given value.
-  ///
-  /// \note The size of the data structure depends on the highest
+  /// This class provides a special graph map type which can store an
+  /// integer value for graph items (\c Node, \c Arc or \c Edge).
+  /// For each non-negative value it is possible to iterate on the keys
+  /// mapped to the value.
+  ///
+  /// This type is a reference map, so it can be modified with the
+  /// subscription operator.
+  ///
+  /// \note The size of the data structure depends on the largest
   /// value in the map.
   ///
-  /// \param GR The graph type.
-  /// \param ITEM One of the graph's item type, the key of the map.
-  template <typename GR, typename ITEM>
+  /// \tparam GR The graph type.
+  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
+  /// \c GR::Edge).
+  ///
+  /// \see IterableBoolMap, IterableValueMap
+  /// \see CrossRefMap
+  template <typename GR, typename K>
   class IterableIntMap
-    : protected ItemSetTraits<GR, ITEM>::
-        template Map<_maps_bits::IterableIntMapNode<ITEM> >::Type {
-  public:
-    typedef typename ItemSetTraits<GR, ITEM>::
-      template Map<_maps_bits::IterableIntMapNode<ITEM> >::Type Parent;
+    : protected ItemSetTraits<GR, K>::
+        template Map<_maps_bits::IterableIntMapNode<K> >::Type {
+  public:
+    typedef typename ItemSetTraits<GR, K>::
+      template Map<_maps_bits::IterableIntMapNode<K> >::Type Parent;
 
     /// The key type
-    typedef ITEM Key;
+    typedef K Key;
     /// The value type
     typedef int Value;
@@ -2705,5 +2716,5 @@
     /// \brief Constructor of the map.
     ///
-    /// Constructor of the map. It set all values to -1.
+    /// Constructor of the map. It sets all values to -1.
     explicit IterableIntMap(const Graph& graph)
       : Parent(graph) {}
@@ -2713,5 +2724,5 @@
     /// Constructor of the map with a given value.
     explicit IterableIntMap(const Graph& graph, int value)
-      : Parent(graph, _maps_bits::IterableIntMapNode<ITEM>(value)) {
+      : Parent(graph, _maps_bits::IterableIntMapNode<K>(value)) {
       if (value >= 0) {
         for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
@@ -2755,11 +2766,11 @@
   public:
 
-    /// Indicates that the map if reference map.
+    /// Indicates that the map is reference map.
     typedef True ReferenceMapTag;
 
-    /// \brief Refernce to the value of the map.
-    ///
-    /// This class is similar to the int type. It can
-    /// be converted to int and it has the same operators.
+    /// \brief Reference to the value of the map.
+    ///
+    /// This class is similar to the \c int type. It can
+    /// be converted to \c int and it has the same operators.
     class Reference {
       friend class IterableIntMap;
@@ -2882,15 +2893,15 @@
     ///
     /// Iterator for the keys with the same value. It works
-    /// like a graph item iterator in the map, it can be converted
+    /// like a graph item iterator, it can be converted to
     /// the item type of the map, incremented with \c ++ operator, and
-    /// if the iterator leave the last valid item it will be equal to
+    /// if the iterator leaves the last valid item, it will be equal to
     /// \c INVALID.
-    class ItemIt : public ITEM {
+    class ItemIt : public Key {
     public:
-      typedef ITEM Parent;
+      typedef Key Parent;
 
       /// \brief Invalid constructor \& conversion.
       ///
-      /// This constructor initializes the item to be invalid.
+      /// This constructor initializes the iterator to be invalid.
       /// \sa Invalid for more details.
       ItemIt(Invalid) : Parent(INVALID), _map(0) {}
@@ -2899,7 +2910,7 @@
       ///
       /// Creates an iterator with a value. It iterates on the
-      /// keys which have the given value.
-      /// \param map The IterableIntMap
-      /// \param value The value
+      /// keys mapped to the given value.
+      /// \param map The IterableIntMap.
+      /// \param value The value.
       ItemIt(const IterableIntMap& map, int value) : _map(&map) {
         if (value < 0 || value >= int(_map->_first.size())) {
@@ -2912,5 +2923,5 @@
       /// \brief Increment operator.
       ///
-      /// Increment Operator.
+      /// Increment operator.
       ItemIt& operator++() {
         Parent::operator=(_map->IterableIntMap::Parent::
@@ -2919,5 +2930,4 @@
       }
 
-
     private:
       const IterableIntMap* _map;
@@ -2944,5 +2954,5 @@
 
   private:
-    std::vector<ITEM> _first;
+    std::vector<Key> _first;
   };
 
@@ -2956,36 +2966,39 @@
   }
 
-  ///\ingroup graph_maps
-  ///
   /// \brief Dynamic iterable map for comparable values.
   ///
-  /// This class provides a special graph map type which can store
-  /// for each graph item(node, edge, etc.) a value. For each
-  /// value it is possible to iterate on the keys which mapped to the
-  /// given value. The type stores for each value a linked list with
+  /// This class provides a special graph map type which can store an
+  /// 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.
+  ///
+  /// The map stores for each value a linked list with
   /// the items which mapped to the value, and the values are stored
   /// in balanced binary tree. The values of the map can be accessed
   /// with stl compatible forward iterator.
   ///
-  /// This type is not reference map so it cannot be modified with
+  /// This type is not reference map, so it cannot be modified with
   /// the subscription operator.
   ///
-  /// \see InvertableMap
-  ///
-  /// \param GR The graph type.
-  /// \param ITEM One of the graph's item type, the key of the map.
-  /// \param VAL Any comparable value type.
-  template <typename GR, typename ITEM, typename VAL>
+  /// \tparam GR The graph type.
+  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
+  /// \c GR::Edge).
+  /// \tparam V The value type of the map. It can be any comparable
+  /// value type.
+  ///
+  /// \see IterableBoolMap, IterableIntMap
+  /// \see CrossRefMap
+  template <typename GR, typename K, typename V>
   class IterableValueMap
-    : protected ItemSetTraits<GR, ITEM>::
-        template Map<_maps_bits::IterableValueMapNode<ITEM, VAL> >::Type {
-  public:
-    typedef typename ItemSetTraits<GR, ITEM>::
-      template Map<_maps_bits::IterableValueMapNode<ITEM, VAL> >::Type Parent;
+    : protected ItemSetTraits<GR, K>::
+        template Map<_maps_bits::IterableValueMapNode<K, V> >::Type {
+  public:
+    typedef typename ItemSetTraits<GR, K>::
+      template Map<_maps_bits::IterableValueMapNode<K, V> >::Type Parent;
 
     /// The key type
-    typedef ITEM Key;
+    typedef K Key;
     /// The value type
-    typedef VAL Value;
+    typedef V Value;
     /// The graph type
     typedef GR Graph;
@@ -2993,10 +3006,10 @@
   public:
 
-    /// \brief Constructor of the Map with a given value.
-    ///
-    /// Constructor of the Map with a given value.
+    /// \brief Constructor of the map with a given value.
+    ///
+    /// Constructor of the map with a given value.
     explicit IterableValueMap(const Graph& graph,
                               const Value& value = Value())
-      : Parent(graph, _maps_bits::IterableValueMapNode<ITEM, VAL>(value)) {
+      : Parent(graph, _maps_bits::IterableValueMapNode<K, V>(value)) {
       for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
         lace(it);
@@ -3027,7 +3040,4 @@
       if (it == _first.end()) {
         node.prev = node.next = INVALID;
-        if (node.next != INVALID) {
-          Parent::operator[](node.next).prev = key;
-        }
         _first.insert(std::make_pair(node.value, key));
       } else {
@@ -3047,6 +3057,5 @@
     /// This iterator is an stl compatible forward
     /// iterator on the values of the map. The values can
-    /// be accessed in the [beginValue, endValue) range.
-    ///
+    /// be accessed in the <tt>[beginValue, endValue)</tt> range.
     class ValueIterator
       : public std::iterator<std::forward_iterator_tag, Value> {
@@ -3080,5 +3089,5 @@
     /// Returns an stl compatible iterator to the
     /// first value of the map. The values of the
-    /// map can be accessed in the [beginValue, endValue)
+    /// map can be accessed in the <tt>[beginValue, endValue)</tt>
     /// range.
     ValueIterator beginValue() const {
@@ -3090,5 +3099,5 @@
     /// Returns an stl compatible iterator after the
     /// last value of the map. The values of the
-    /// map can be accessed in the [beginValue, endValue)
+    /// map can be accessed in the <tt>[beginValue, endValue)</tt>
     /// range.
     ValueIterator endValue() const {
@@ -3115,15 +3124,15 @@
     ///
     /// Iterator for the keys with the same value. It works
-    /// like a graph item iterator in the map, it can be converted
+    /// like a graph item iterator, it can be converted to
     /// the item type of the map, incremented with \c ++ operator, and
-    /// if the iterator leave the last valid item it will be equal to
+    /// if the iterator leaves the last valid item, it will be equal to
     /// \c INVALID.
-    class ItemIt : public ITEM {
+    class ItemIt : public Key {
     public:
-      typedef ITEM Parent;
+      typedef Key Parent;
 
       /// \brief Invalid constructor \& conversion.
       ///
-      /// This constructor initializes the item to be invalid.
+      /// This constructor initializes the iterator to be invalid.
       /// \sa Invalid for more details.
       ItemIt(Invalid) : Parent(INVALID), _map(0) {}
Index: test/maps_test.cc
===================================================================
--- test/maps_test.cc	(revision 740)
+++ test/maps_test.cc	(revision 741)
@@ -23,4 +23,5 @@
 #include <lemon/concepts/maps.h>
 #include <lemon/maps.h>
+#include <lemon/smart_graph.h>
 
 #include "test_tools.h"
@@ -356,5 +357,5 @@
 
     typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm;
-    checkConcept<ReadWriteMap<Item, int>, Ibm>();
+    checkConcept<ReferenceMap<Item, bool, bool&, const bool&>, Ibm>();
 
     const int num = 10;
@@ -437,5 +438,5 @@
     typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim;
 
-    checkConcept<ReadWriteMap<Item, int>, Iim>();
+    checkConcept<ReferenceMap<Item, int, int&, const int&>, Iim>();
 
     const int num = 10;
@@ -468,5 +469,5 @@
     int n = 0;
     for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 0, "Wrong Value");
+      check(map1[static_cast<Item>(it)] == 0, "Wrong value");
       ++n;
     }
@@ -474,5 +475,5 @@
 
     for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 1, "Wrong Value");
+      check(map1[static_cast<Item>(it)] == 1, "Wrong value");
       ++n;
     }
@@ -525,5 +526,5 @@
     int n = 0;
     for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 0.0, "Wrong Value");
+      check(map1[static_cast<Item>(it)] == 0.0, "Wrong value");
       ++n;
     }
@@ -531,5 +532,5 @@
 
     for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 1.0, "Wrong Value");
+      check(map1[static_cast<Item>(it)] == 1.0, "Wrong value");
       ++n;
     }
