COIN-OR::LEMON - Graph Library

Changeset 1669:66ae78d29f1e in lemon-0.x for lemon/bits/default_map.h


Ignore:
Timestamp:
08/31/05 15:29:32 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2185
Message:

Template assign operator for graph maps.

Some naming and coding conventions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/default_map.h

    r1587 r1669  
    2929namespace lemon {
    3030
    31 /// \addtogroup graphmapfactory
    32 /// @{
    33 
    34   /** The ArrayMap template class is graph map structure what
    35    *  automatically updates the map when a key is added to or erased from
    36    *  the map. This map uses the VectorMap if the Value is a primitive
    37    *  type and the ArrayMap for the other cases.
    38    *
    39    *  The template parameter is the MapRegistry that the maps
    40    *  will belong to and the Value.
    41    */
    42 
    43 
     31  /// \addtogroup graphmapfactory
     32  /// @{
    4433
    4534  template <typename _Graph, typename _Item, typename _Value>
     
    136125  };
    137126
    138 
    139 
     127  /// \e
    140128  template <
    141129    typename _Graph,
     
    153141    DefaultMap(const Graph& _g) : Parent(_g) {}
    154142    DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {}
    155   };
    156 
    157 
    158 
     143
     144  };
     145
     146
     147  /// \e
    159148  template <typename _Base>
    160   class DefaultMappableGraphExtender : public _Base {
     149  class MappableGraphExtender : public _Base {
    161150  public:
    162151
    163     typedef DefaultMappableGraphExtender<_Base> Graph;
     152    typedef MappableGraphExtender<_Base> Graph;
    164153    typedef _Base Parent;
    165154
     
    175164      : public IterableMapExtender<DefaultMap<Graph, Node, _Value> > {
    176165    public:
    177       typedef DefaultMappableGraphExtender Graph;
     166      typedef MappableGraphExtender Graph;
    178167      typedef IterableMapExtender<DefaultMap<Graph, Node, _Value> > Parent;
    179168
     
    182171      NodeMap(const Graph& _g, const _Value& _v)
    183172        : Parent(_g, _v) {}
     173
     174      /// \brief Template assign operator.
     175      ///
     176      /// The given parameter should be conform to the ReadMap
     177      /// concecpt and could be indiced by the current item set of
     178      /// the NodeMap. In this case the value for each item
     179      /// is assigned by the value of the given ReadMap.
     180      template <typename CMap>
     181      NodeMap& operator=(const CMap& cmap) {
     182        checkConcept<concept::ReadMap<Node, _Value>, CMap>();
     183        const typename Parent::Graph* graph = Parent::getGraph();
     184        Node it;
     185        for (graph->first(it); it != INVALID; graph->next(it)) {
     186          Parent::set(it, cmap[it]);
     187        }
     188        return *this;
     189      }
     190
    184191    };
    185192
     
    188195      : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
    189196    public:
    190       typedef DefaultMappableGraphExtender Graph;
     197      typedef MappableGraphExtender Graph;
    191198      typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
    192199
     
    195202      EdgeMap(const Graph& _g, const _Value& _v)
    196203        : Parent(_g, _v) {}
     204
     205      template <typename CMap>
     206      EdgeMap& operator=(const CMap& cmap) {
     207        checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
     208        const typename Parent::Graph* graph = Parent::getGraph();
     209        Edge it;
     210        for (graph->first(it); it != INVALID; graph->next(it)) {
     211          Parent::set(it, cmap[it]);
     212        }
     213        return *this;
     214      }
    197215    };
    198216   
    199217  };
    200218
     219  /// \e
    201220  template <typename _Base>
    202221  class MappableUndirGraphExtender :
    203     public DefaultMappableGraphExtender<_Base> {
     222    public MappableGraphExtender<_Base> {
    204223  public:
    205224
    206225    typedef MappableUndirGraphExtender Graph;
    207     typedef DefaultMappableGraphExtender<_Base> Parent;
     226    typedef MappableGraphExtender<_Base> Parent;
    208227
    209228    typedef typename Parent::UndirEdge UndirEdge;
     
    221240      UndirEdgeMap(const Graph& _g, const _Value& _v)
    222241        : Parent(_g, _v) {}
     242
     243      template <typename CMap>
     244      UndirEdgeMap& operator=(const CMap& cmap) {
     245        checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
     246        const typename Parent::Graph* graph = Parent::getGraph();
     247        UndirEdge it;
     248        for (graph->first(it); it != INVALID; graph->next(it)) {
     249          Parent::set(it, cmap[it]);
     250        }
     251        return *this;
     252      }
    223253    };
    224254
     
    226256  };
    227257
     258  /// @}
    228259}
    229260
Note: See TracChangeset for help on using the changeset viewer.