diff -r d5a7d6bc0f00 -r 66ae78d29f1e lemon/bits/default_map.h --- a/lemon/bits/default_map.h Tue Aug 30 21:19:07 2005 +0000 +++ b/lemon/bits/default_map.h Wed Aug 31 13:29:32 2005 +0000 @@ -28,19 +28,8 @@ namespace lemon { -/// \addtogroup graphmapfactory -/// @{ - - /** The ArrayMap template class is graph map structure what - * automatically updates the map when a key is added to or erased from - * the map. This map uses the VectorMap if the Value is a primitive - * type and the ArrayMap for the other cases. - * - * The template parameter is the MapRegistry that the maps - * will belong to and the Value. - */ - - + /// \addtogroup graphmapfactory + /// @{ template struct DefaultMapSelector { @@ -135,8 +124,7 @@ typedef VectorMap<_Graph, _Item, _Ptr*> Map; }; - - + /// \e template < typename _Graph, typename _Item, @@ -152,15 +140,16 @@ DefaultMap(const Graph& _g) : Parent(_g) {} DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {} + }; - + /// \e template - class DefaultMappableGraphExtender : public _Base { + class MappableGraphExtender : public _Base { public: - typedef DefaultMappableGraphExtender<_Base> Graph; + typedef MappableGraphExtender<_Base> Graph; typedef _Base Parent; typedef typename Parent::Node Node; @@ -174,37 +163,67 @@ class NodeMap : public IterableMapExtender > { public: - typedef DefaultMappableGraphExtender Graph; + typedef MappableGraphExtender Graph; typedef IterableMapExtender > Parent; NodeMap(const Graph& _g) : Parent(_g) {} NodeMap(const Graph& _g, const _Value& _v) : Parent(_g, _v) {} + + /// \brief Template assign operator. + /// + /// The given parameter should be conform to the ReadMap + /// concecpt and could be indiced by the current item set of + /// the NodeMap. In this case the value for each item + /// is assigned by the value of the given ReadMap. + template + NodeMap& operator=(const CMap& cmap) { + checkConcept, CMap>(); + const typename Parent::Graph* graph = Parent::getGraph(); + Node it; + for (graph->first(it); it != INVALID; graph->next(it)) { + Parent::set(it, cmap[it]); + } + return *this; + } + }; template class EdgeMap : public IterableMapExtender > { public: - typedef DefaultMappableGraphExtender Graph; + typedef MappableGraphExtender Graph; typedef IterableMapExtender > Parent; EdgeMap(const Graph& _g) : Parent(_g) {} EdgeMap(const Graph& _g, const _Value& _v) : Parent(_g, _v) {} + + template + EdgeMap& operator=(const CMap& cmap) { + checkConcept, CMap>(); + const typename Parent::Graph* graph = Parent::getGraph(); + Edge it; + for (graph->first(it); it != INVALID; graph->next(it)) { + Parent::set(it, cmap[it]); + } + return *this; + } }; }; + /// \e template class MappableUndirGraphExtender : - public DefaultMappableGraphExtender<_Base> { + public MappableGraphExtender<_Base> { public: typedef MappableUndirGraphExtender Graph; - typedef DefaultMappableGraphExtender<_Base> Parent; + typedef MappableGraphExtender<_Base> Parent; typedef typename Parent::UndirEdge UndirEdge; @@ -220,11 +239,23 @@ : Parent(_g) {} UndirEdgeMap(const Graph& _g, const _Value& _v) : Parent(_g, _v) {} + + template + UndirEdgeMap& operator=(const CMap& cmap) { + checkConcept, CMap>(); + const typename Parent::Graph* graph = Parent::getGraph(); + UndirEdge it; + for (graph->first(it); it != INVALID; graph->next(it)) { + Parent::set(it, cmap[it]); + } + return *this; + } }; }; + /// @} } #endif