# HG changeset patch # User Peter Kovacs # Date 1239698052 -7200 # Node ID 2313edd0db0bc70d7c72eca4b0404f79ef22ea61 # Parent d11bf79989052e478a8691be32c34c28c598c92b Standard graph maps are required to be reference maps (#190) diff -r d11bf7998905 -r 2313edd0db0b lemon/bits/graph_adaptor_extender.h --- a/lemon/bits/graph_adaptor_extender.h Tue Apr 14 10:33:17 2009 +0200 +++ b/lemon/bits/graph_adaptor_extender.h Tue Apr 14 10:34:12 2009 +0200 @@ -22,8 +22,6 @@ #include #include -#include - namespace lemon { template diff -r d11bf7998905 -r 2313edd0db0b lemon/bits/map_extender.h --- a/lemon/bits/map_extender.h Tue Apr 14 10:33:17 2009 +0200 +++ b/lemon/bits/map_extender.h Tue Apr 14 10:34:12 2009 +0200 @@ -47,6 +47,8 @@ typedef typename Parent::Key Key; typedef typename Parent::Value Value; + typedef typename Parent::Reference Reference; + typedef typename Parent::ConstReference ConstReference; class MapIt; class ConstMapIt; @@ -187,6 +189,8 @@ typedef typename Parent::Key Key; typedef typename Parent::Value Value; + typedef typename Parent::Reference Reference; + typedef typename Parent::ConstReference ConstReference; class MapIt; class ConstMapIt; diff -r d11bf7998905 -r 2313edd0db0b lemon/concepts/digraph.h --- a/lemon/concepts/digraph.h Tue Apr 14 10:33:17 2009 +0200 +++ b/lemon/concepts/digraph.h Tue Apr 14 10:34:12 2009 +0200 @@ -421,12 +421,11 @@ /// Gives back the opposite node on the given arc. Node oppositeNode(const Node&, const Arc&) const { return INVALID; } - /// \brief Read write map of the nodes to type \c T. + /// \brief Reference map of the nodes to type \c T. /// - /// ReadWrite map of the nodes to type \c T. - /// \sa Reference + /// Reference map of the nodes to type \c T. template - class NodeMap : public ReadWriteMap< Node, T > { + class NodeMap : public ReferenceMap { public: ///\e @@ -436,7 +435,8 @@ private: ///Copy constructor - NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } + NodeMap(const NodeMap& nm) : + ReferenceMap(nm) { } ///Assignment operator template NodeMap& operator=(const CMap&) { @@ -445,12 +445,11 @@ } }; - /// \brief Read write map of the arcs to type \c T. + /// \brief Reference map of the arcs to type \c T. /// /// Reference map of the arcs to type \c T. - /// \sa Reference template - class ArcMap : public ReadWriteMap { + class ArcMap : public ReferenceMap { public: ///\e @@ -459,7 +458,8 @@ ArcMap(const Digraph&, T) { } private: ///Copy constructor - ArcMap(const ArcMap& em) : ReadWriteMap(em) { } + ArcMap(const ArcMap& em) : + ReferenceMap(em) { } ///Assignment operator template ArcMap& operator=(const CMap&) { @@ -471,6 +471,7 @@ template struct Constraints { void constraints() { + checkConcept(); checkConcept, _Digraph>(); checkConcept, _Digraph>(); checkConcept, _Digraph>(); diff -r d11bf7998905 -r 2313edd0db0b lemon/concepts/graph.h --- a/lemon/concepts/graph.h Tue Apr 14 10:33:17 2009 +0200 +++ b/lemon/concepts/graph.h Tue Apr 14 10:34:12 2009 +0200 @@ -497,12 +497,11 @@ InArcIt& operator++() { return *this; } }; - /// \brief Read write map of the nodes to type \c T. + /// \brief Reference map of the nodes to type \c T. /// - /// ReadWrite map of the nodes to type \c T. - /// \sa Reference + /// Reference map of the nodes to type \c T. template - class NodeMap : public ReadWriteMap< Node, T > + class NodeMap : public ReferenceMap { public: @@ -513,7 +512,8 @@ private: ///Copy constructor - NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } + NodeMap(const NodeMap& nm) : + ReferenceMap(nm) { } ///Assignment operator template NodeMap& operator=(const CMap&) { @@ -522,12 +522,11 @@ } }; - /// \brief Read write map of the directed arcs to type \c T. + /// \brief Reference map of the arcs to type \c T. /// - /// Reference map of the directed arcs to type \c T. - /// \sa Reference + /// Reference map of the arcs to type \c T. template - class ArcMap : public ReadWriteMap + class ArcMap : public ReferenceMap { public: @@ -537,7 +536,8 @@ ArcMap(const Graph&, T) { } private: ///Copy constructor - ArcMap(const ArcMap& em) : ReadWriteMap(em) { } + ArcMap(const ArcMap& em) : + ReferenceMap(em) { } ///Assignment operator template ArcMap& operator=(const CMap&) { @@ -546,12 +546,11 @@ } }; - /// Read write map of the edges to type \c T. + /// Reference map of the edges to type \c T. - /// Reference map of the arcs to type \c T. - /// \sa Reference + /// Reference map of the edges to type \c T. template - class EdgeMap : public ReadWriteMap + class EdgeMap : public ReferenceMap { public: @@ -561,7 +560,8 @@ EdgeMap(const Graph&, T) { } private: ///Copy constructor - EdgeMap(const EdgeMap& em) : ReadWriteMap(em) {} + EdgeMap(const EdgeMap& em) : + ReferenceMap(em) {} ///Assignment operator template EdgeMap& operator=(const CMap&) { @@ -748,6 +748,7 @@ template struct Constraints { void constraints() { + checkConcept(); checkConcept, _Graph>(); checkConcept, _Graph>(); checkConcept, _Graph>(); diff -r d11bf7998905 -r 2313edd0db0b lemon/concepts/graph_components.h --- a/lemon/concepts/graph_components.h Tue Apr 14 10:33:17 2009 +0200 +++ b/lemon/concepts/graph_components.h Tue Apr 14 10:34:12 2009 +0200 @@ -988,8 +988,9 @@ /// This class describes the concept of standard graph maps, i.e. /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and /// graph types, which can be used for associating data to graph items. + /// The standard graph maps must conform to the ReferenceMap concept. template - class GraphMap : public ReadWriteMap { + class GraphMap : public ReferenceMap { public: typedef ReadWriteMap Parent; @@ -1000,6 +1001,13 @@ typedef K Key; /// The value type of the map. typedef V Value; + /// The reference type of the map. + typedef Value& Reference; + /// The const reference type of the map. + typedef const Value& ConstReference; + + // The reference map tag. + typedef True ReferenceMapTag; /// \brief Construct a new map. /// @@ -1031,7 +1039,8 @@ template struct Constraints { void constraints() { - checkConcept, _Map >(); + checkConcept + , _Map>(); _Map m1(g); _Map m2(g,t); @@ -1073,6 +1082,7 @@ /// \brief Standard graph map for the nodes. /// /// Standard graph map for the nodes. + /// It conforms to the ReferenceMap concept. template class NodeMap : public GraphMap { public: @@ -1110,6 +1120,7 @@ /// \brief Standard graph map for the arcs. /// /// Standard graph map for the arcs. + /// It conforms to the ReferenceMap concept. template class ArcMap : public GraphMap { public: @@ -1207,6 +1218,7 @@ /// \brief Standard graph map for the edges. /// /// Standard graph map for the edges. + /// It conforms to the ReferenceMap concept. template class EdgeMap : public GraphMap { public: