Standard graph maps are required to be reference maps (#190)
authorPeter Kovacs <kpeter@inf.elte.hu>
Tue, 14 Apr 2009 10:34:12 +0200
changeset 5722313edd0db0b
parent 571 d11bf7998905
child 573 aa1804409f29
Standard graph maps are required to be reference maps (#190)
lemon/bits/graph_adaptor_extender.h
lemon/bits/map_extender.h
lemon/concepts/digraph.h
lemon/concepts/graph.h
lemon/concepts/graph_components.h
     1.1 --- a/lemon/bits/graph_adaptor_extender.h	Tue Apr 14 10:33:17 2009 +0200
     1.2 +++ b/lemon/bits/graph_adaptor_extender.h	Tue Apr 14 10:34:12 2009 +0200
     1.3 @@ -22,8 +22,6 @@
     1.4  #include <lemon/core.h>
     1.5  #include <lemon/error.h>
     1.6  
     1.7 -#include <lemon/bits/default_map.h>
     1.8 -
     1.9  namespace lemon {
    1.10  
    1.11    template <typename _Digraph>
     2.1 --- a/lemon/bits/map_extender.h	Tue Apr 14 10:33:17 2009 +0200
     2.2 +++ b/lemon/bits/map_extender.h	Tue Apr 14 10:34:12 2009 +0200
     2.3 @@ -47,6 +47,8 @@
     2.4  
     2.5      typedef typename Parent::Key Key;
     2.6      typedef typename Parent::Value Value;
     2.7 +    typedef typename Parent::Reference Reference;
     2.8 +    typedef typename Parent::ConstReference ConstReference;
     2.9  
    2.10      class MapIt;
    2.11      class ConstMapIt;
    2.12 @@ -187,6 +189,8 @@
    2.13  
    2.14      typedef typename Parent::Key Key;
    2.15      typedef typename Parent::Value Value;
    2.16 +    typedef typename Parent::Reference Reference;
    2.17 +    typedef typename Parent::ConstReference ConstReference;
    2.18  
    2.19      class MapIt;
    2.20      class ConstMapIt;
     3.1 --- a/lemon/concepts/digraph.h	Tue Apr 14 10:33:17 2009 +0200
     3.2 +++ b/lemon/concepts/digraph.h	Tue Apr 14 10:34:12 2009 +0200
     3.3 @@ -421,12 +421,11 @@
     3.4        /// Gives back the opposite node on the given arc.
     3.5        Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
     3.6  
     3.7 -      /// \brief Read write map of the nodes to type \c T.
     3.8 +      /// \brief Reference map of the nodes to type \c T.
     3.9        ///
    3.10 -      /// ReadWrite map of the nodes to type \c T.
    3.11 -      /// \sa Reference
    3.12 +      /// Reference map of the nodes to type \c T.
    3.13        template<class T>
    3.14 -      class NodeMap : public ReadWriteMap< Node, T > {
    3.15 +      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
    3.16        public:
    3.17  
    3.18          ///\e
    3.19 @@ -436,7 +435,8 @@
    3.20  
    3.21        private:
    3.22          ///Copy constructor
    3.23 -        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
    3.24 +        NodeMap(const NodeMap& nm) : 
    3.25 +          ReferenceMap<Node, T, T&, const T&>(nm) { }
    3.26          ///Assignment operator
    3.27          template <typename CMap>
    3.28          NodeMap& operator=(const CMap&) {
    3.29 @@ -445,12 +445,11 @@
    3.30          }
    3.31        };
    3.32  
    3.33 -      /// \brief Read write map of the arcs to type \c T.
    3.34 +      /// \brief Reference map of the arcs to type \c T.
    3.35        ///
    3.36        /// Reference map of the arcs to type \c T.
    3.37 -      /// \sa Reference
    3.38        template<class T>
    3.39 -      class ArcMap : public ReadWriteMap<Arc,T> {
    3.40 +      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
    3.41        public:
    3.42  
    3.43          ///\e
    3.44 @@ -459,7 +458,8 @@
    3.45          ArcMap(const Digraph&, T) { }
    3.46        private:
    3.47          ///Copy constructor
    3.48 -        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
    3.49 +        ArcMap(const ArcMap& em) :
    3.50 +          ReferenceMap<Arc, T, T&, const T&>(em) { }
    3.51          ///Assignment operator
    3.52          template <typename CMap>
    3.53          ArcMap& operator=(const CMap&) {
    3.54 @@ -471,6 +471,7 @@
    3.55        template <typename _Digraph>
    3.56        struct Constraints {
    3.57          void constraints() {
    3.58 +          checkConcept<BaseDigraphComponent, _Digraph>();
    3.59            checkConcept<IterableDigraphComponent<>, _Digraph>();
    3.60            checkConcept<IDableDigraphComponent<>, _Digraph>();
    3.61            checkConcept<MappableDigraphComponent<>, _Digraph>();
     4.1 --- a/lemon/concepts/graph.h	Tue Apr 14 10:33:17 2009 +0200
     4.2 +++ b/lemon/concepts/graph.h	Tue Apr 14 10:34:12 2009 +0200
     4.3 @@ -497,12 +497,11 @@
     4.4          InArcIt& operator++() { return *this; }
     4.5        };
     4.6  
     4.7 -      /// \brief Read write map of the nodes to type \c T.
     4.8 +      /// \brief Reference map of the nodes to type \c T.
     4.9        ///
    4.10 -      /// ReadWrite map of the nodes to type \c T.
    4.11 -      /// \sa Reference
    4.12 +      /// Reference map of the nodes to type \c T.
    4.13        template<class T>
    4.14 -      class NodeMap : public ReadWriteMap< Node, T >
    4.15 +      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
    4.16        {
    4.17        public:
    4.18  
    4.19 @@ -513,7 +512,8 @@
    4.20  
    4.21        private:
    4.22          ///Copy constructor
    4.23 -        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
    4.24 +        NodeMap(const NodeMap& nm) :
    4.25 +          ReferenceMap<Node, T, T&, const T&>(nm) { }
    4.26          ///Assignment operator
    4.27          template <typename CMap>
    4.28          NodeMap& operator=(const CMap&) {
    4.29 @@ -522,12 +522,11 @@
    4.30          }
    4.31        };
    4.32  
    4.33 -      /// \brief Read write map of the directed arcs to type \c T.
    4.34 +      /// \brief Reference map of the arcs to type \c T.
    4.35        ///
    4.36 -      /// Reference map of the directed arcs to type \c T.
    4.37 -      /// \sa Reference
    4.38 +      /// Reference map of the arcs to type \c T.
    4.39        template<class T>
    4.40 -      class ArcMap : public ReadWriteMap<Arc,T>
    4.41 +      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
    4.42        {
    4.43        public:
    4.44  
    4.45 @@ -537,7 +536,8 @@
    4.46          ArcMap(const Graph&, T) { }
    4.47        private:
    4.48          ///Copy constructor
    4.49 -        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
    4.50 +        ArcMap(const ArcMap& em) :
    4.51 +          ReferenceMap<Arc, T, T&, const T&>(em) { }
    4.52          ///Assignment operator
    4.53          template <typename CMap>
    4.54          ArcMap& operator=(const CMap&) {
    4.55 @@ -546,12 +546,11 @@
    4.56          }
    4.57        };
    4.58  
    4.59 -      /// Read write map of the edges to type \c T.
    4.60 +      /// Reference map of the edges to type \c T.
    4.61  
    4.62 -      /// Reference map of the arcs to type \c T.
    4.63 -      /// \sa Reference
    4.64 +      /// Reference map of the edges to type \c T.
    4.65        template<class T>
    4.66 -      class EdgeMap : public ReadWriteMap<Edge,T>
    4.67 +      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
    4.68        {
    4.69        public:
    4.70  
    4.71 @@ -561,7 +560,8 @@
    4.72          EdgeMap(const Graph&, T) { }
    4.73        private:
    4.74          ///Copy constructor
    4.75 -        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
    4.76 +        EdgeMap(const EdgeMap& em) :
    4.77 +          ReferenceMap<Edge, T, T&, const T&>(em) {}
    4.78          ///Assignment operator
    4.79          template <typename CMap>
    4.80          EdgeMap& operator=(const CMap&) {
    4.81 @@ -748,6 +748,7 @@
    4.82        template <typename _Graph>
    4.83        struct Constraints {
    4.84          void constraints() {
    4.85 +          checkConcept<BaseGraphComponent, _Graph>();
    4.86            checkConcept<IterableGraphComponent<>, _Graph>();
    4.87            checkConcept<IDableGraphComponent<>, _Graph>();
    4.88            checkConcept<MappableGraphComponent<>, _Graph>();
     5.1 --- a/lemon/concepts/graph_components.h	Tue Apr 14 10:33:17 2009 +0200
     5.2 +++ b/lemon/concepts/graph_components.h	Tue Apr 14 10:34:12 2009 +0200
     5.3 @@ -988,8 +988,9 @@
     5.4      /// This class describes the concept of standard graph maps, i.e.
     5.5      /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
     5.6      /// graph types, which can be used for associating data to graph items.
     5.7 +    /// The standard graph maps must conform to the ReferenceMap concept.
     5.8      template <typename GR, typename K, typename V>
     5.9 -    class GraphMap : public ReadWriteMap<K, V> {
    5.10 +    class GraphMap : public ReferenceMap<K, V, V&, const V&> {
    5.11      public:
    5.12  
    5.13        typedef ReadWriteMap<K, V> Parent;
    5.14 @@ -1000,6 +1001,13 @@
    5.15        typedef K Key;
    5.16        /// The value type of the map.
    5.17        typedef V Value;
    5.18 +      /// The reference type of the map.
    5.19 +      typedef Value& Reference;
    5.20 +      /// The const reference type of the map.
    5.21 +      typedef const Value& ConstReference;
    5.22 +
    5.23 +      // The reference map tag.
    5.24 +      typedef True ReferenceMapTag;
    5.25  
    5.26        /// \brief Construct a new map.
    5.27        ///
    5.28 @@ -1031,7 +1039,8 @@
    5.29        template<typename _Map>
    5.30        struct Constraints {
    5.31          void constraints() {
    5.32 -          checkConcept<ReadWriteMap<Key, Value>, _Map >();
    5.33 +          checkConcept
    5.34 +            <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
    5.35            _Map m1(g);
    5.36            _Map m2(g,t);
    5.37            
    5.38 @@ -1073,6 +1082,7 @@
    5.39        /// \brief Standard graph map for the nodes.
    5.40        ///
    5.41        /// Standard graph map for the nodes.
    5.42 +      /// It conforms to the ReferenceMap concept.
    5.43        template <typename V>
    5.44        class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
    5.45        public:
    5.46 @@ -1110,6 +1120,7 @@
    5.47        /// \brief Standard graph map for the arcs.
    5.48        ///
    5.49        /// Standard graph map for the arcs.
    5.50 +      /// It conforms to the ReferenceMap concept.
    5.51        template <typename V>
    5.52        class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
    5.53        public:
    5.54 @@ -1207,6 +1218,7 @@
    5.55        /// \brief Standard graph map for the edges.
    5.56        ///
    5.57        /// Standard graph map for the edges.
    5.58 +      /// It conforms to the ReferenceMap concept.
    5.59        template <typename V>
    5.60        class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
    5.61        public: