Changeset 1999:2ff283124dfc in lemon0.x for lemon/matrix_maps.h
 Timestamp:
 03/06/06 11:28:37 (14 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2609
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/matrix_maps.h
r1993 r1999 210 210 template <typename _Graph, typename _Item, typename _Value> 211 211 class DynamicMatrixMap 212 : protected AlterationNotifier<_Item>::ObserverBase { 213 public: 214 typedef typename AlterationNotifier<_Item>::ObserverBase Parent; 212 : protected ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { 213 public: 214 typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase 215 Parent; 215 216 216 217 typedef _Graph Graph; … … 236 237 /// Creates an item matrix for the given graph. 237 238 DynamicMatrixMap(const Graph& _graph) 238 : graph(_graph),values(size(_graph.maxId(Key()) + 1)) {239 Parent::attach( graph.getNotifier(Key()));239 : values(size(_graph.maxId(Key()) + 1)) { 240 Parent::attach(_graph.getNotifier(Key())); 240 241 } 241 242 … … 245 246 /// pairs of keys the given parameter. 246 247 DynamicMatrixMap(const Graph& _graph, const Value& _val) 247 : graph(_graph), values(size(_graph.maxId(Key()) + 1), _val) { 248 Parent::attach(graph.getNotifier(Key())); 249 } 250 251 ~DynamicMatrixMap() { 252 if (Parent::attached()) { 253 Parent::detach(); 254 } 248 : values(size(_graph.maxId(Key()) + 1), _val) { 249 Parent::attach(_graph.getNotifier(Key())); 255 250 } 256 251 … … 260 255 /// Gives back the value assigned to the \c first  \c second ordered pair. 261 256 ConstReference operator()(const Key& first, const Key& second) const { 262 return values[index(graph.id(first), graph.id(second))]; 257 return values[index(Parent::getNotifier()>id(first), 258 Parent::getNotifier()>id(second))]; 263 259 } 264 260 … … 268 264 /// Gives back the value assigned to the \c first  \c second ordered pair. 269 265 Reference operator()(const Key& first, const Key& second) { 270 return values[index(graph.id(first), graph.id(second))]; 266 return values[index(Parent::getNotifier()>id(first), 267 Parent::getNotifier()>id(second))]; 271 268 } 272 269 … … 275 272 /// Setter function for the matrix map. 276 273 void set(const Key& first, const Key& second, const Value& val) { 277 values[index(graph.id(first), graph.id(second))] = val; 274 values[index(Parent::getNotifier()>id(first), 275 Parent::getNotifier()>id(second))] = val; 278 276 } 279 277 … … 293 291 294 292 virtual void add(const Key& key) { 295 if (size( graph.id(key) + 1) >= (int)values.size()) {296 values.resize(size( graph.id(key) + 1));293 if (size(Parent::getNotifier()>id(key) + 1) >= (int)values.size()) { 294 values.resize(size(Parent::getNotifier()>id(key) + 1)); 297 295 } 298 296 } … … 301 299 302 300 virtual void build() { 303 values.resize(size( graph.maxId(Key()) + 1));301 values.resize(size(Parent::getNotifier()>maxId() + 1)); 304 302 } 305 303 … … 309 307 310 308 private: 311 const Graph& graph;312 309 std::vector<Value> values; 313 310 }; … … 321 318 template <typename _Graph, typename _Item, typename _Value> 322 319 class DynamicSymMatrixMap 323 : protected AlterationNotifier<_Item>::ObserverBase { 324 public: 325 typedef typename AlterationNotifier<_Item>::ObserverBase Parent; 320 : protected ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { 321 public: 322 typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase 323 Parent; 326 324 327 325 typedef _Graph Graph; … … 347 345 /// Creates an item matrix for the given graph. 348 346 DynamicSymMatrixMap(const Graph& _graph) 349 : graph(_graph),values(size(_graph.maxId(Key()) + 1)) {350 Parent::attach( graph.getNotifier(Key()));347 : values(size(_graph.maxId(Key()) + 1)) { 348 Parent::attach(_graph.getNotifier(Key())); 351 349 } 352 350 … … 356 354 /// pairs of keys the given parameter. 357 355 DynamicSymMatrixMap(const Graph& _graph, const Value& _val) 358 : graph(_graph), values(size(_graph.maxId(Key()) + 1), _val) { 359 Parent::attach(graph.getNotifier(Key())); 360 } 361 362 ~DynamicSymMatrixMap() { 363 if (Parent::attached()) { 364 Parent::detach(); 365 } 356 : values(size(_graph.maxId(Key()) + 1), _val) { 357 Parent::attach(_graph.getNotifier(Key())); 366 358 } 367 359 … … 372 364 /// pair. 373 365 ConstReference operator()(const Key& first, const Key& second) const { 374 return values[index(graph.id(first), graph.id(second))]; 366 return values[index(Parent::getNotifier()>id(first), 367 Parent::getNotifier()>id(second))]; 375 368 } 376 369 … … 381 374 /// pair. 382 375 Reference operator()(const Key& first, const Key& second) { 383 return values[index(graph.id(first), graph.id(second))]; 376 return values[index(Parent::getNotifier()>id(first), 377 Parent::getNotifier()>id(second))]; 384 378 } 385 379 … … 388 382 /// Setter function for the matrix map. 389 383 void set(const Key& first, const Key& second, const Value& val) { 390 values[index(graph.id(first), graph.id(second))] = val; 384 values[index(Parent::getNotifier()>id(first), 385 Parent::getNotifier()>id(second))] = val; 391 386 } 392 387 … … 406 401 407 402 virtual void add(const Key& key) { 408 if (size( graph.id(key) + 1) >= (int)values.size()) {409 values.resize(size( graph.id(key) + 1));403 if (size(Parent::getNotifier()>id(key) + 1) >= (int)values.size()) { 404 values.resize(size(Parent::getNotifier()>id(key) + 1)); 410 405 } 411 406 } … … 414 409 415 410 virtual void build() { 416 values.resize(size( graph.maxId(Key()) + 1));411 values.resize(size(Parent::getNotifier()>maxId() + 1)); 417 412 } 418 413 … … 422 417 423 418 private: 424 const Graph& graph;425 419 std::vector<Value> values; 426 420 };
Note: See TracChangeset
for help on using the changeset viewer.