# HG changeset patch # User Alpar Juttner # Date 1238826658 -3600 # Node ID be6646ac5d89466468e28e85735bd19a42df6b64 # Parent eda12d8ac95313c837f493e8fd2ca49adc49de26 DescriptorMap->RangeIdMap, InvertableMap->CrossRefMap (#160) diff -r eda12d8ac953 -r be6646ac5d89 lemon/maps.h --- a/lemon/maps.h Wed Apr 01 14:18:35 2009 +0100 +++ b/lemon/maps.h Sat Apr 04 07:30:58 2009 +0100 @@ -1832,7 +1832,7 @@ /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or /// \c GR::Edge). /// - /// \see DescriptorMap + /// \see RangeIdMap template class IdMap : public MapBase { public: @@ -1898,7 +1898,7 @@ }; - /// \brief General invertable graph map type. + /// \brief General cross reference graph map type. /// This class provides simple invertable graph maps. /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap" @@ -1915,7 +1915,7 @@ /// /// \see IterableValueMap template - class InvertableMap + class CrossRefMap : protected ItemSetTraits::template Map::Type { private: @@ -1927,19 +1927,19 @@ public: - /// The graph type of InvertableMap. + /// The graph type of CrossRefMap. typedef GR Graph; - /// The key type of InvertableMap (\c Node, \c Arc or \c Edge). + /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). typedef K Item; - /// The key type of InvertableMap (\c Node, \c Arc or \c Edge). + /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). typedef K Key; - /// The value type of InvertableMap. + /// The value type of CrossRefMap. typedef V Value; /// \brief Constructor. /// - /// Construct a new InvertableMap for the given graph. - explicit InvertableMap(const Graph& graph) : Map(graph) {} + /// Construct a new CrossRefMap for the given graph. + explicit CrossRefMap(const Graph& graph) : Map(graph) {} /// \brief Forward iterator for values. /// @@ -1948,7 +1948,7 @@ /// be accessed in the [beginValue, endValue) range. class ValueIterator : public std::iterator { - friend class InvertableMap; + friend class CrossRefMap; private: ValueIterator(typename Container::const_iterator _it) : it(_it) {} @@ -2072,13 +2072,13 @@ /// \brief Constructor /// /// Constructor of the InverseMap. - explicit InverseMap(const InvertableMap& inverted) + explicit InverseMap(const CrossRefMap& inverted) : _inverted(inverted) {} /// The value type of the InverseMap. - typedef typename InvertableMap::Key Value; + typedef typename CrossRefMap::Key Value; /// The key type of the InverseMap. - typedef typename InvertableMap::Value Key; + typedef typename CrossRefMap::Value Key; /// \brief Subscript operator. /// @@ -2089,7 +2089,7 @@ } private: - const InvertableMap& _inverted; + const CrossRefMap& _inverted; }; /// \brief It gives back the read-only inverse map. @@ -2101,18 +2101,17 @@ }; - /// \brief Provides a mutable, continuous and unique descriptor for each - /// item in a graph. + /// \brief Provides continuous and unique ID for the + /// items of a graph. /// - /// DescriptorMap provides a unique and continuous (but mutable) - /// descriptor (id) for each item of the same type (\c Node, \c Arc or + /// RangeIdMap provides a unique and continuous + /// ID for each item of a given type (\c Node, \c Arc or /// \c Edge) in a graph. This id is /// - \b unique: different items get different ids, /// - \b continuous: the range of the ids is the set of integers /// between 0 and \c n-1, where \c n is the number of the items of - /// this type (\c Node, \c Arc or \c Edge). So the id of an item can - /// change if you delete an other item of the same type, i.e. this - /// id is mutable. + /// this type (\c Node, \c Arc or \c Edge). + /// - So, the ids can change when deleting an item of the same type. /// /// Thus this id is not (necessarily) the same as what can get using /// the \c id() function of the graph or \ref IdMap. @@ -2125,25 +2124,25 @@ /// /// \see IdMap template - class DescriptorMap + class RangeIdMap : protected ItemSetTraits::template Map::Type { typedef typename ItemSetTraits::template Map::Type Map; public: - /// The graph type of DescriptorMap. + /// The graph type of RangeIdMap. typedef GR Graph; - /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge). + /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). typedef K Item; - /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge). + /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). typedef K Key; - /// The value type of DescriptorMap. + /// The value type of RangeIdMap. typedef int Value; /// \brief Constructor. /// - /// Constructor for descriptor map. - explicit DescriptorMap(const Graph& gr) : Map(gr) { + /// Constructor. + explicit RangeIdMap(const Graph& gr) : Map(gr) { Item it; const typename Map::Notifier* nf = Map::notifier(); for (nf->first(it); it != INVALID; nf->next(it)) { @@ -2244,16 +2243,16 @@ _inv_map[pi] = q; } - /// \brief Gives back the \e descriptor of the item. + /// \brief Gives back the \e RangeId of the item /// - /// Gives back the mutable and unique \e descriptor of the map. + /// Gives back the \e RangeId of the item. int operator[](const Item& item) const { return Map::operator[](item); } - /// \brief Gives back the item by its descriptor. - /// - /// Gives back th item by its descriptor. + /// \brief Gives back the item belonging to a \e RangeId + /// + /// Gives back the item belonging to a \e RangeId. Item operator()(int id) const { return _inv_map[id]; } @@ -2265,22 +2264,22 @@ public: - /// \brief The inverse map type of DescriptorMap. + /// \brief The inverse map type of RangeIdMap. /// - /// The inverse map type of DescriptorMap. + /// The inverse map type of RangeIdMap. class InverseMap { public: /// \brief Constructor /// /// Constructor of the InverseMap. - explicit InverseMap(const DescriptorMap& inverted) + explicit InverseMap(const RangeIdMap& inverted) : _inverted(inverted) {} /// The value type of the InverseMap. - typedef typename DescriptorMap::Key Value; + typedef typename RangeIdMap::Key Value; /// The key type of the InverseMap. - typedef typename DescriptorMap::Value Key; + typedef typename RangeIdMap::Value Key; /// \brief Subscript operator. /// @@ -2298,7 +2297,7 @@ } private: - const DescriptorMap& _inverted; + const RangeIdMap& _inverted; }; /// \brief Gives back the inverse of the map. diff -r eda12d8ac953 -r be6646ac5d89 test/graph_utils_test.cc --- a/test/graph_utils_test.cc Wed Apr 01 14:18:35 2009 +0100 +++ b/test/graph_utils_test.cc Sat Apr 04 07:30:58 2009 +0100 @@ -38,15 +38,15 @@ for (int i = 0; i < 10; ++i) { digraph.addNode(); } - DescriptorMap nodes(digraph); - typename DescriptorMap::InverseMap invNodes(nodes); + RangeIdMap nodes(digraph); + typename RangeIdMap::InverseMap invNodes(nodes); for (int i = 0; i < 100; ++i) { int src = rnd[invNodes.size()]; int trg = rnd[invNodes.size()]; digraph.addArc(invNodes[src], invNodes[trg]); } typename Digraph::template ArcMap found(digraph, false); - DescriptorMap arcs(digraph); + RangeIdMap arcs(digraph); for (NodeIt src(digraph); src != INVALID; ++src) { for (NodeIt trg(digraph); trg != INVALID; ++trg) { for (ConArcIt con(digraph, src, trg); con != INVALID; ++con) { @@ -113,15 +113,15 @@ for (int i = 0; i < 10; ++i) { graph.addNode(); } - DescriptorMap nodes(graph); - typename DescriptorMap::InverseMap invNodes(nodes); + RangeIdMap nodes(graph); + typename RangeIdMap::InverseMap invNodes(nodes); for (int i = 0; i < 100; ++i) { int src = rnd[invNodes.size()]; int trg = rnd[invNodes.size()]; graph.addEdge(invNodes[src], invNodes[trg]); } typename Graph::template EdgeMap found(graph, 0); - DescriptorMap edges(graph); + RangeIdMap edges(graph); for (NodeIt src(graph); src != INVALID; ++src) { for (NodeIt trg(graph); trg != INVALID; ++trg) { for (ConEdgeIt con(graph, src, trg); con != INVALID; ++con) {