Changeset 1669:66ae78d29f1e in lemon-0.x for lemon/bits/default_map.h
- Timestamp:
- 08/31/05 15:29:32 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2185
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/default_map.h
r1587 r1669 29 29 namespace lemon { 30 30 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 /// @{ 44 33 45 34 template <typename _Graph, typename _Item, typename _Value> … … 136 125 }; 137 126 138 139 127 /// \e 140 128 template < 141 129 typename _Graph, … … 153 141 DefaultMap(const Graph& _g) : Parent(_g) {} 154 142 DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {} 155 }; 156 157 158 143 144 }; 145 146 147 /// \e 159 148 template <typename _Base> 160 class DefaultMappableGraphExtender : public _Base {149 class MappableGraphExtender : public _Base { 161 150 public: 162 151 163 typedef DefaultMappableGraphExtender<_Base> Graph;152 typedef MappableGraphExtender<_Base> Graph; 164 153 typedef _Base Parent; 165 154 … … 175 164 : public IterableMapExtender<DefaultMap<Graph, Node, _Value> > { 176 165 public: 177 typedef DefaultMappableGraphExtender Graph;166 typedef MappableGraphExtender Graph; 178 167 typedef IterableMapExtender<DefaultMap<Graph, Node, _Value> > Parent; 179 168 … … 182 171 NodeMap(const Graph& _g, const _Value& _v) 183 172 : 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 184 191 }; 185 192 … … 188 195 : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > { 189 196 public: 190 typedef DefaultMappableGraphExtender Graph;197 typedef MappableGraphExtender Graph; 191 198 typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent; 192 199 … … 195 202 EdgeMap(const Graph& _g, const _Value& _v) 196 203 : 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 } 197 215 }; 198 216 199 217 }; 200 218 219 /// \e 201 220 template <typename _Base> 202 221 class MappableUndirGraphExtender : 203 public DefaultMappableGraphExtender<_Base> {222 public MappableGraphExtender<_Base> { 204 223 public: 205 224 206 225 typedef MappableUndirGraphExtender Graph; 207 typedef DefaultMappableGraphExtender<_Base> Parent;226 typedef MappableGraphExtender<_Base> Parent; 208 227 209 228 typedef typename Parent::UndirEdge UndirEdge; … … 221 240 UndirEdgeMap(const Graph& _g, const _Value& _v) 222 241 : 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 } 223 253 }; 224 254 … … 226 256 }; 227 257 258 /// @} 228 259 } 229 260
Note: See TracChangeset
for help on using the changeset viewer.