DescriptorMap->RangeIdMap, InvertableMap->CrossRefMap (#160)
authorAlpar Juttner <alpar@cs.elte.hu>
Sat, 04 Apr 2009 07:30:58 +0100
changeset 564be6646ac5d89
parent 556 eda12d8ac953
child 565 37216ca5b9c6
DescriptorMap->RangeIdMap, InvertableMap->CrossRefMap (#160)
lemon/maps.h
test/graph_utils_test.cc
     1.1 --- a/lemon/maps.h	Wed Apr 01 14:18:35 2009 +0100
     1.2 +++ b/lemon/maps.h	Sat Apr 04 07:30:58 2009 +0100
     1.3 @@ -1832,7 +1832,7 @@
     1.4    /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
     1.5    /// \c GR::Edge).
     1.6    ///
     1.7 -  /// \see DescriptorMap
     1.8 +  /// \see RangeIdMap
     1.9    template <typename GR, typename K>
    1.10    class IdMap : public MapBase<K, int> {
    1.11    public:
    1.12 @@ -1898,7 +1898,7 @@
    1.13    };
    1.14  
    1.15  
    1.16 -  /// \brief General invertable graph map type.
    1.17 +  /// \brief General cross reference graph map type.
    1.18  
    1.19    /// This class provides simple invertable graph maps.
    1.20    /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap"
    1.21 @@ -1915,7 +1915,7 @@
    1.22    ///
    1.23    /// \see IterableValueMap
    1.24    template <typename GR, typename K, typename V>
    1.25 -  class InvertableMap
    1.26 +  class CrossRefMap
    1.27      : protected ItemSetTraits<GR, K>::template Map<V>::Type {
    1.28    private:
    1.29  
    1.30 @@ -1927,19 +1927,19 @@
    1.31  
    1.32    public:
    1.33  
    1.34 -    /// The graph type of InvertableMap.
    1.35 +    /// The graph type of CrossRefMap.
    1.36      typedef GR Graph;
    1.37 -    /// The key type of InvertableMap (\c Node, \c Arc or \c Edge).
    1.38 +    /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge).
    1.39      typedef K Item;
    1.40 -    /// The key type of InvertableMap (\c Node, \c Arc or \c Edge).
    1.41 +    /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge).
    1.42      typedef K Key;
    1.43 -    /// The value type of InvertableMap.
    1.44 +    /// The value type of CrossRefMap.
    1.45      typedef V Value;
    1.46  
    1.47      /// \brief Constructor.
    1.48      ///
    1.49 -    /// Construct a new InvertableMap for the given graph.
    1.50 -    explicit InvertableMap(const Graph& graph) : Map(graph) {}
    1.51 +    /// Construct a new CrossRefMap for the given graph.
    1.52 +    explicit CrossRefMap(const Graph& graph) : Map(graph) {}
    1.53  
    1.54      /// \brief Forward iterator for values.
    1.55      ///
    1.56 @@ -1948,7 +1948,7 @@
    1.57      /// be accessed in the <tt>[beginValue, endValue)</tt> range.
    1.58      class ValueIterator
    1.59        : public std::iterator<std::forward_iterator_tag, Value> {
    1.60 -      friend class InvertableMap;
    1.61 +      friend class CrossRefMap;
    1.62      private:
    1.63        ValueIterator(typename Container::const_iterator _it)
    1.64          : it(_it) {}
    1.65 @@ -2072,13 +2072,13 @@
    1.66        /// \brief Constructor
    1.67        ///
    1.68        /// Constructor of the InverseMap.
    1.69 -      explicit InverseMap(const InvertableMap& inverted)
    1.70 +      explicit InverseMap(const CrossRefMap& inverted)
    1.71          : _inverted(inverted) {}
    1.72  
    1.73        /// The value type of the InverseMap.
    1.74 -      typedef typename InvertableMap::Key Value;
    1.75 +      typedef typename CrossRefMap::Key Value;
    1.76        /// The key type of the InverseMap.
    1.77 -      typedef typename InvertableMap::Value Key;
    1.78 +      typedef typename CrossRefMap::Value Key;
    1.79  
    1.80        /// \brief Subscript operator.
    1.81        ///
    1.82 @@ -2089,7 +2089,7 @@
    1.83        }
    1.84  
    1.85      private:
    1.86 -      const InvertableMap& _inverted;
    1.87 +      const CrossRefMap& _inverted;
    1.88      };
    1.89  
    1.90      /// \brief It gives back the read-only inverse map.
    1.91 @@ -2101,18 +2101,17 @@
    1.92  
    1.93    };
    1.94  
    1.95 -  /// \brief Provides a mutable, continuous and unique descriptor for each
    1.96 -  /// item in a graph.
    1.97 +  /// \brief Provides continuous and unique ID for the
    1.98 +  /// items of a graph.
    1.99    ///
   1.100 -  /// DescriptorMap provides a unique and continuous (but mutable)
   1.101 -  /// descriptor (id) for each item of the same type (\c Node, \c Arc or
   1.102 +  /// RangeIdMap provides a unique and continuous
   1.103 +  /// ID for each item of a given type (\c Node, \c Arc or
   1.104    /// \c Edge) in a graph. This id is
   1.105    ///  - \b unique: different items get different ids,
   1.106    ///  - \b continuous: the range of the ids is the set of integers
   1.107    ///    between 0 and \c n-1, where \c n is the number of the items of
   1.108 -  ///    this type (\c Node, \c Arc or \c Edge). So the id of an item can
   1.109 -  ///    change if you delete an other item of the same type, i.e. this
   1.110 -  ///    id is mutable.
   1.111 +  ///    this type (\c Node, \c Arc or \c Edge).
   1.112 +  ///  - So, the ids can change when deleting an item of the same type.
   1.113    ///
   1.114    /// Thus this id is not (necessarily) the same as what can get using
   1.115    /// the \c id() function of the graph or \ref IdMap.
   1.116 @@ -2125,25 +2124,25 @@
   1.117    ///
   1.118    /// \see IdMap
   1.119    template <typename GR, typename K>
   1.120 -  class DescriptorMap
   1.121 +  class RangeIdMap
   1.122      : protected ItemSetTraits<GR, K>::template Map<int>::Type {
   1.123  
   1.124      typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map;
   1.125  
   1.126    public:
   1.127 -    /// The graph type of DescriptorMap.
   1.128 +    /// The graph type of RangeIdMap.
   1.129      typedef GR Graph;
   1.130 -    /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge).
   1.131 +    /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
   1.132      typedef K Item;
   1.133 -    /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge).
   1.134 +    /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
   1.135      typedef K Key;
   1.136 -    /// The value type of DescriptorMap.
   1.137 +    /// The value type of RangeIdMap.
   1.138      typedef int Value;
   1.139  
   1.140      /// \brief Constructor.
   1.141      ///
   1.142 -    /// Constructor for descriptor map.
   1.143 -    explicit DescriptorMap(const Graph& gr) : Map(gr) {
   1.144 +    /// Constructor.
   1.145 +    explicit RangeIdMap(const Graph& gr) : Map(gr) {
   1.146        Item it;
   1.147        const typename Map::Notifier* nf = Map::notifier();
   1.148        for (nf->first(it); it != INVALID; nf->next(it)) {
   1.149 @@ -2244,16 +2243,16 @@
   1.150        _inv_map[pi] = q;
   1.151      }
   1.152  
   1.153 -    /// \brief Gives back the \e descriptor of the item.
   1.154 +    /// \brief Gives back the \e RangeId of the item
   1.155      ///
   1.156 -    /// Gives back the mutable and unique \e descriptor of the map.
   1.157 +    /// Gives back the \e RangeId of the item.
   1.158      int operator[](const Item& item) const {
   1.159        return Map::operator[](item);
   1.160      }
   1.161  
   1.162 -    /// \brief Gives back the item by its descriptor.
   1.163 -    ///
   1.164 -    /// Gives back th item by its descriptor.
   1.165 +    /// \brief Gives back the item belonging to a \e RangeId
   1.166 +    /// 
   1.167 +    /// Gives back the item belonging to a \e RangeId.
   1.168      Item operator()(int id) const {
   1.169        return _inv_map[id];
   1.170      }
   1.171 @@ -2265,22 +2264,22 @@
   1.172  
   1.173    public:
   1.174  
   1.175 -    /// \brief The inverse map type of DescriptorMap.
   1.176 +    /// \brief The inverse map type of RangeIdMap.
   1.177      ///
   1.178 -    /// The inverse map type of DescriptorMap.
   1.179 +    /// The inverse map type of RangeIdMap.
   1.180      class InverseMap {
   1.181      public:
   1.182        /// \brief Constructor
   1.183        ///
   1.184        /// Constructor of the InverseMap.
   1.185 -      explicit InverseMap(const DescriptorMap& inverted)
   1.186 +      explicit InverseMap(const RangeIdMap& inverted)
   1.187          : _inverted(inverted) {}
   1.188  
   1.189  
   1.190        /// The value type of the InverseMap.
   1.191 -      typedef typename DescriptorMap::Key Value;
   1.192 +      typedef typename RangeIdMap::Key Value;
   1.193        /// The key type of the InverseMap.
   1.194 -      typedef typename DescriptorMap::Value Key;
   1.195 +      typedef typename RangeIdMap::Value Key;
   1.196  
   1.197        /// \brief Subscript operator.
   1.198        ///
   1.199 @@ -2298,7 +2297,7 @@
   1.200        }
   1.201  
   1.202      private:
   1.203 -      const DescriptorMap& _inverted;
   1.204 +      const RangeIdMap& _inverted;
   1.205      };
   1.206  
   1.207      /// \brief Gives back the inverse of the map.
     2.1 --- a/test/graph_utils_test.cc	Wed Apr 01 14:18:35 2009 +0100
     2.2 +++ b/test/graph_utils_test.cc	Sat Apr 04 07:30:58 2009 +0100
     2.3 @@ -38,15 +38,15 @@
     2.4      for (int i = 0; i < 10; ++i) {
     2.5        digraph.addNode();
     2.6      }
     2.7 -    DescriptorMap<Digraph, Node> nodes(digraph);
     2.8 -    typename DescriptorMap<Digraph, Node>::InverseMap invNodes(nodes);
     2.9 +    RangeIdMap<Digraph, Node> nodes(digraph);
    2.10 +    typename RangeIdMap<Digraph, Node>::InverseMap invNodes(nodes);
    2.11      for (int i = 0; i < 100; ++i) {
    2.12        int src = rnd[invNodes.size()];
    2.13        int trg = rnd[invNodes.size()];
    2.14        digraph.addArc(invNodes[src], invNodes[trg]);
    2.15      }
    2.16      typename Digraph::template ArcMap<bool> found(digraph, false);
    2.17 -    DescriptorMap<Digraph, Arc> arcs(digraph);
    2.18 +    RangeIdMap<Digraph, Arc> arcs(digraph);
    2.19      for (NodeIt src(digraph); src != INVALID; ++src) {
    2.20        for (NodeIt trg(digraph); trg != INVALID; ++trg) {
    2.21          for (ConArcIt<Digraph> con(digraph, src, trg); con != INVALID; ++con) {
    2.22 @@ -113,15 +113,15 @@
    2.23    for (int i = 0; i < 10; ++i) {
    2.24      graph.addNode();
    2.25    }
    2.26 -  DescriptorMap<Graph, Node> nodes(graph);
    2.27 -  typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
    2.28 +  RangeIdMap<Graph, Node> nodes(graph);
    2.29 +  typename RangeIdMap<Graph, Node>::InverseMap invNodes(nodes);
    2.30    for (int i = 0; i < 100; ++i) {
    2.31      int src = rnd[invNodes.size()];
    2.32      int trg = rnd[invNodes.size()];
    2.33      graph.addEdge(invNodes[src], invNodes[trg]);
    2.34    }
    2.35    typename Graph::template EdgeMap<int> found(graph, 0);
    2.36 -  DescriptorMap<Graph, Edge> edges(graph);
    2.37 +  RangeIdMap<Graph, Edge> edges(graph);
    2.38    for (NodeIt src(graph); src != INVALID; ++src) {
    2.39      for (NodeIt trg(graph); trg != INVALID; ++trg) {
    2.40        for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) {