COIN-OR::LEMON - Graph Library

Ticket #190: ref-maps2-63e0373c4caa.patch

File ref-maps2-63e0373c4caa.patch, 8.9 KB (added by Peter Kovacs, 16 years ago)

Perform changes

  • lemon/bits/graph_adaptor_extender.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1239290144 -7200
    # Node ID 63e0373c4caa2e888dfdfb0403353f3b0c0f7e83
    # Parent  add8195ad331e8e75b4abe4f09a323a1dbca061f
    Standard graph maps are required to be reference maps (#190)
    
    diff --git a/lemon/bits/graph_adaptor_extender.h b/lemon/bits/graph_adaptor_extender.h
    a b  
    2222#include <lemon/core.h>
    2323#include <lemon/error.h>
    2424
    25 #include <lemon/bits/default_map.h>
    26 
    2725namespace lemon {
    2826
    2927  template <typename _Digraph>
  • lemon/bits/map_extender.h

    diff --git a/lemon/bits/map_extender.h b/lemon/bits/map_extender.h
    a b  
    4747
    4848    typedef typename Parent::Key Key;
    4949    typedef typename Parent::Value Value;
     50    typedef typename Parent::Reference Reference;
     51    typedef typename Parent::ConstReference ConstReference;
    5052
    5153    class MapIt;
    5254    class ConstMapIt;
     
    187189
    188190    typedef typename Parent::Key Key;
    189191    typedef typename Parent::Value Value;
     192    typedef typename Parent::Reference Reference;
     193    typedef typename Parent::ConstReference ConstReference;
    190194
    191195    class MapIt;
    192196    class ConstMapIt;
  • lemon/concepts/digraph.h

    diff --git a/lemon/concepts/digraph.h b/lemon/concepts/digraph.h
    a b  
    421421      /// Gives back the opposite node on the given arc.
    422422      Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
    423423
    424       /// \brief Read write map of the nodes to type \c T.
     424      /// \brief Reference map of the nodes to type \c T.
    425425      ///
    426       /// ReadWrite map of the nodes to type \c T.
    427       /// \sa Reference
     426      /// Reference map of the nodes to type \c T.
    428427      template<class T>
    429       class NodeMap : public ReadWriteMap< Node, T > {
     428      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
    430429      public:
    431430
    432431        ///\e
     
    436435
    437436      private:
    438437        ///Copy constructor
    439         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
     438        NodeMap(const NodeMap& nm) :
     439          ReferenceMap<Node, T, T&, const T&>(nm) { }
    440440        ///Assignment operator
    441441        template <typename CMap>
    442442        NodeMap& operator=(const CMap&) {
     
    445445        }
    446446      };
    447447
    448       /// \brief Read write map of the arcs to type \c T.
     448      /// \brief Reference map of the arcs to type \c T.
    449449      ///
    450450      /// Reference map of the arcs to type \c T.
    451       /// \sa Reference
    452451      template<class T>
    453       class ArcMap : public ReadWriteMap<Arc,T> {
     452      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
    454453      public:
    455454
    456455        ///\e
     
    459458        ArcMap(const Digraph&, T) { }
    460459      private:
    461460        ///Copy constructor
    462         ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
     461        ArcMap(const ArcMap& em) :
     462          ReferenceMap<Arc, T, T&, const T&>(em) { }
    463463        ///Assignment operator
    464464        template <typename CMap>
    465465        ArcMap& operator=(const CMap&) {
     
    471471      template <typename _Digraph>
    472472      struct Constraints {
    473473        void constraints() {
     474          checkConcept<BaseDigraphComponent, _Digraph>();
    474475          checkConcept<IterableDigraphComponent<>, _Digraph>();
    475476          checkConcept<IDableDigraphComponent<>, _Digraph>();
    476477          checkConcept<MappableDigraphComponent<>, _Digraph>();
  • lemon/concepts/graph.h

    diff --git a/lemon/concepts/graph.h b/lemon/concepts/graph.h
    a b  
    497497        InArcIt& operator++() { return *this; }
    498498      };
    499499
    500       /// \brief Read write map of the nodes to type \c T.
     500      /// \brief Reference map of the nodes to type \c T.
    501501      ///
    502       /// ReadWrite map of the nodes to type \c T.
    503       /// \sa Reference
     502      /// Reference map of the nodes to type \c T.
    504503      template<class T>
    505       class NodeMap : public ReadWriteMap< Node, T >
     504      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
    506505      {
    507506      public:
    508507
     
    513512
    514513      private:
    515514        ///Copy constructor
    516         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
     515        NodeMap(const NodeMap& nm) :
     516          ReferenceMap<Node, T, T&, const T&>(nm) { }
    517517        ///Assignment operator
    518518        template <typename CMap>
    519519        NodeMap& operator=(const CMap&) {
     
    522522        }
    523523      };
    524524
    525       /// \brief Read write map of the directed arcs to type \c T.
     525      /// \brief Reference map of the arcs to type \c T.
    526526      ///
    527       /// Reference map of the directed arcs to type \c T.
    528       /// \sa Reference
     527      /// Reference map of the arcs to type \c T.
    529528      template<class T>
    530       class ArcMap : public ReadWriteMap<Arc,T>
     529      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
    531530      {
    532531      public:
    533532
     
    537536        ArcMap(const Graph&, T) { }
    538537      private:
    539538        ///Copy constructor
    540         ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
     539        ArcMap(const ArcMap& em) :
     540          ReferenceMap<Arc, T, T&, const T&>(em) { }
    541541        ///Assignment operator
    542542        template <typename CMap>
    543543        ArcMap& operator=(const CMap&) {
     
    546546        }
    547547      };
    548548
    549       /// Read write map of the edges to type \c T.
     549      /// Reference map of the edges to type \c T.
    550550
    551       /// Reference map of the arcs to type \c T.
    552       /// \sa Reference
     551      /// Reference map of the edges to type \c T.
    553552      template<class T>
    554       class EdgeMap : public ReadWriteMap<Edge,T>
     553      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
    555554      {
    556555      public:
    557556
     
    561560        EdgeMap(const Graph&, T) { }
    562561      private:
    563562        ///Copy constructor
    564         EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
     563        EdgeMap(const EdgeMap& em) :
     564          ReferenceMap<Edge, T, T&, const T&>(em) {}
    565565        ///Assignment operator
    566566        template <typename CMap>
    567567        EdgeMap& operator=(const CMap&) {
     
    748748      template <typename _Graph>
    749749      struct Constraints {
    750750        void constraints() {
     751          checkConcept<BaseGraphComponent, _Graph>();
    751752          checkConcept<IterableGraphComponent<>, _Graph>();
    752753          checkConcept<IDableGraphComponent<>, _Graph>();
    753754          checkConcept<MappableGraphComponent<>, _Graph>();
  • lemon/concepts/graph_components.h

    diff --git a/lemon/concepts/graph_components.h b/lemon/concepts/graph_components.h
    a b  
    988988    /// This class describes the concept of standard graph maps, i.e.
    989989    /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
    990990    /// graph types, which can be used for associating data to graph items.
     991    /// The standard graph maps must conform to the ReferenceMap concept.
    991992    template <typename GR, typename K, typename V>
    992     class GraphMap : public ReadWriteMap<K, V> {
     993    class GraphMap : public ReferenceMap<K, V, V&, const V&> {
    993994    public:
    994995
    995996      typedef ReadWriteMap<K, V> Parent;
     
    10001001      typedef K Key;
    10011002      /// The value type of the map.
    10021003      typedef V Value;
     1004      /// The reference type of the map.
     1005      typedef Value& Reference;
     1006      /// The const reference type of the map.
     1007      typedef const Value& ConstReference;
     1008
     1009      // The reference map tag.
     1010      typedef True ReferenceMapTag;
    10031011
    10041012      /// \brief Construct a new map.
    10051013      ///
     
    10311039      template<typename _Map>
    10321040      struct Constraints {
    10331041        void constraints() {
    1034           checkConcept<ReadWriteMap<Key, Value>, _Map >();
     1042          checkConcept
     1043            <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
    10351044          _Map m1(g);
    10361045          _Map m2(g,t);
    10371046         
     
    10731082      /// \brief Standard graph map for the nodes.
    10741083      ///
    10751084      /// Standard graph map for the nodes.
     1085      /// It conforms to the ReferenceMap concept.
    10761086      template <typename V>
    1077       class NodeMap : public GraphMap<Digraph, Node, V> {
     1087      class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
    10781088      public:
    10791089        typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
    10801090
     
    11101120      /// \brief Standard graph map for the arcs.
    11111121      ///
    11121122      /// Standard graph map for the arcs.
     1123      /// It conforms to the ReferenceMap concept.
    11131124      template <typename V>
    1114       class ArcMap : public GraphMap<Digraph, Arc, V> {
     1125      class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
    11151126      public:
    11161127        typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
    11171128
     
    12071218      /// \brief Standard graph map for the edges.
    12081219      ///
    12091220      /// Standard graph map for the edges.
     1221      /// It conforms to the ReferenceMap concept.
    12101222      template <typename V>
    1211       class EdgeMap : public GraphMap<Graph, Edge, V> {
     1223      class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
    12121224      public:
    12131225        typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
    12141226