Changeset 980:0f1044b7a3af in lemon0.x for src/lemon/vector_map.h
 Timestamp:
 11/11/04 10:31:55 (15 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1368
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/vector_map.h
r979 r980 47 47 template <typename _Graph, 48 48 typename _Item, 49 typename _IdMap,50 49 typename _Value> 51 50 class VectorMap : public AlterationObserverRegistry<_Item>::ObserverBase { … … 57 56 typedef _Item KeyType; 58 57 /// The id map type of the map. 59 typedef _IdMap IdMap;60 /// The registry type of the map.61 58 typedef AlterationObserverRegistry<_Item> Registry; 62 59 /// The value type of the map. … … 94 91 /// It adds all the items of the graph to the map. 95 92 96 VectorMap(const Graph& _g , Registry& _r) : graph(&_g) {97 attach(_ r);93 VectorMap(const Graph& _g) : graph(&_g) { 94 attach(_g.getObserverRegistry(_Item())); 98 95 build(); 99 96 } … … 104 101 /// It adds all the items of the graph to the map. 105 102 106 VectorMap(const Graph& g, Registry& r, const Value& v) : graph(&g) {107 attach( r);108 container.resize( IdMap(*graph).maxId() + 1,v);109 } 110 111 VectorMap(const VectorMap& copy) : graph(copy.getGraph()) {112 if ( copy.attached()) {113 attach(* copy.getRegistry());114 container = copy.container;103 VectorMap(const Graph& _g, const Value& _v) : graph(&_g) { 104 attach(_g.getObserverRegistry(_Item())); 105 container.resize(graph>maxId(_Item()) + 1, _v); 106 } 107 108 VectorMap(const VectorMap& _copy) : graph(_copy.getGraph()) { 109 if (_copy.attached()) { 110 attach(*_copy.getRegistry()); 111 container = _copy.container; 115 112 } 116 113 } … … 155 152 156 153 ReferenceType operator[](const KeyType& key) { 157 return container[ IdMap(*graph)[key]];154 return container[graph>id(key)]; 158 155 } 159 156 … … 164 161 165 162 ConstReferenceType operator[](const KeyType& key) const { 166 return container[ IdMap(*graph)[key]];163 return container[graph>id(key)]; 167 164 } 168 165 … … 183 180 184 181 void add(const KeyType& key) { 185 int id = IdMap(*graph)[key];182 int id = graph>id(key); 186 183 if (id >= (int)container.size()) { 187 184 container.resize(id + 1); … … 201 198 202 199 void build() { 203 container.resize( IdMap(*graph).maxId() + 1);200 container.resize(graph>maxId(_Item()) + 1); 204 201 } 205 202 … … 240 237 241 238 template <typename _Value> 242 class NodeMap : public VectorMap<Graph, Node, NodeIdMap,_Value> {239 class NodeMap : public VectorMap<Graph, Node, _Value> { 243 240 public: 244 241 typedef VectorMappableGraphExtender<_Base> Graph; 245 242 246 243 typedef typename Graph::Node Node; 247 typedef typename Graph::NodeIdMap NodeIdMap; 248 249 typedef VectorMap<Graph, Node, NodeIdMap, _Value> Parent; 244 245 typedef VectorMap<Graph, Node, _Value> Parent; 250 246 251 247 //typedef typename Parent::Graph Graph; … … 253 249 254 250 NodeMap(const Graph& g) 255 : Parent(g , g.getNodeObserverRegistry()) {}251 : Parent(g) {} 256 252 NodeMap(const Graph& g, const Value& v) 257 : Parent(g, g.getNodeObserverRegistry(),v) {}253 : Parent(g, v) {} 258 254 259 255 }; 260 256 261 257 template <typename _Value> 262 class EdgeMap : public VectorMap<Graph, Edge, EdgeIdMap,_Value> {258 class EdgeMap : public VectorMap<Graph, Edge, _Value> { 263 259 public: 264 260 typedef VectorMappableGraphExtender<_Base> Graph; 265 261 266 262 typedef typename Graph::Edge Edge; 267 typedef typename Graph::EdgeIdMap EdgeIdMap; 268 269 typedef VectorMap<Graph, Edge, EdgeIdMap, _Value> Parent; 263 264 typedef VectorMap<Graph, Edge, _Value> Parent; 270 265 271 266 //typedef typename Parent::Graph Graph; … … 273 268 274 269 EdgeMap(const Graph& g) 275 : Parent(g , g.getEdgeObserverRegistry()) {}270 : Parent(g) {} 276 271 EdgeMap(const Graph& g, const Value& v) 277 : Parent(g, g.getEdgeObserverRegistry(),v) {}272 : Parent(g, v) {} 278 273 279 274 };
Note: See TracChangeset
for help on using the changeset viewer.