Changeset 2384:805c5a2a36dd in lemon-0.x for lemon/matrix_maps.h
- Timestamp:
- 03/01/07 18:14:24 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3215
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/matrix_maps.h
r2376 r2384 271 271 DynamicMatrixMap(const Graph& _graph) 272 272 : values(size(_graph.maxId(Key()) + 1)) { 273 Parent::attach(_graph. getNotifier(Key()));273 Parent::attach(_graph.notifier(Key())); 274 274 } 275 275 … … 280 280 DynamicMatrixMap(const Graph& _graph, const Value& _val) 281 281 : values(size(_graph.maxId(Key()) + 1), _val) { 282 Parent::attach(_graph. getNotifier(Key()));282 Parent::attach(_graph.notifier(Key())); 283 283 } 284 284 … … 297 297 DynamicMatrixMap& operator=(const CMap& _cmap){ 298 298 checkConcept<concepts::ReadMatrixMap<FirstKey, SecondKey, Value>, CMap>(); 299 typename Parent::Notifier* notifier = Parent:: getNotifier();299 typename Parent::Notifier* notifier = Parent::notifier(); 300 300 Key first, second; 301 301 for(notifier->first(first); first != INVALID; … … 314 314 /// Gives back the value assigned to the \c first - \c second ordered pair. 315 315 ConstReference operator()(const Key& first, const Key& second) const { 316 return values[index(Parent:: getNotifier()->id(first),317 Parent:: getNotifier()->id(second))];316 return values[index(Parent::notifier()->id(first), 317 Parent::notifier()->id(second))]; 318 318 } 319 319 … … 323 323 /// Gives back the value assigned to the \c first - \c second ordered pair. 324 324 Reference operator()(const Key& first, const Key& second) { 325 return values[index(Parent:: getNotifier()->id(first),326 Parent:: getNotifier()->id(second))];325 return values[index(Parent::notifier()->id(first), 326 Parent::notifier()->id(second))]; 327 327 } 328 328 … … 331 331 /// Setter function for the matrix map. 332 332 void set(const Key& first, const Key& second, const Value& val) { 333 values[index(Parent:: getNotifier()->id(first),334 Parent:: getNotifier()->id(second))] = val;333 values[index(Parent::notifier()->id(first), 334 Parent::notifier()->id(second))] = val; 335 335 } 336 336 … … 350 350 351 351 virtual void add(const Key& key) { 352 if (size(Parent:: getNotifier()->id(key) + 1) >= (int)values.size()) {353 values.resize(size(Parent:: getNotifier()->id(key) + 1));352 if (size(Parent::notifier()->id(key) + 1) >= (int)values.size()) { 353 values.resize(size(Parent::notifier()->id(key) + 1)); 354 354 } 355 355 } … … 358 358 int new_size = 0; 359 359 for (int i = 0; i < (int)keys.size(); ++i) { 360 if (size(Parent:: getNotifier()->id(keys[i]) + 1) >= new_size) {361 new_size = size(Parent:: getNotifier()->id(keys[i]) + 1);360 if (size(Parent::notifier()->id(keys[i]) + 1) >= new_size) { 361 new_size = size(Parent::notifier()->id(keys[i]) + 1); 362 362 } 363 363 } … … 372 372 373 373 virtual void build() { 374 values.resize(size(Parent:: getNotifier()->maxId() + 1));374 values.resize(size(Parent::notifier()->maxId() + 1)); 375 375 } 376 376 … … 420 420 DynamicSymMatrixMap(const Graph& _graph) 421 421 : values(size(_graph.maxId(Key()) + 1)) { 422 Parent::attach(_graph. getNotifier(Key()));422 Parent::attach(_graph.notifier(Key())); 423 423 } 424 424 … … 429 429 DynamicSymMatrixMap(const Graph& _graph, const Value& _val) 430 430 : values(size(_graph.maxId(Key()) + 1), _val) { 431 Parent::attach(_graph. getNotifier(Key()));431 Parent::attach(_graph.notifier(Key())); 432 432 } 433 433 … … 448 448 DynamicSymMatrixMap& operator=(const CMap& _cmap){ 449 449 checkConcept<concepts::ReadMatrixMap<FirstKey, SecondKey, Value>, CMap>(); 450 typename Parent::Notifier* notifier = Parent:: getNotifier();450 typename Parent::Notifier* notifier = Parent::notifier(); 451 451 Key first, second; 452 452 for(notifier->first(first); first != INVALID; … … 467 467 /// pair. 468 468 ConstReference operator()(const Key& first, const Key& second) const { 469 return values[index(Parent:: getNotifier()->id(first),470 Parent:: getNotifier()->id(second))];469 return values[index(Parent::notifier()->id(first), 470 Parent::notifier()->id(second))]; 471 471 } 472 472 … … 477 477 /// pair. 478 478 Reference operator()(const Key& first, const Key& second) { 479 return values[index(Parent:: getNotifier()->id(first),480 Parent:: getNotifier()->id(second))];479 return values[index(Parent::notifier()->id(first), 480 Parent::notifier()->id(second))]; 481 481 } 482 482 … … 486 486 /// 487 487 void set(const Key& first, const Key& second, const Value& val) { 488 values[index(Parent:: getNotifier()->id(first),489 Parent:: getNotifier()->id(second))] = val;488 values[index(Parent::notifier()->id(first), 489 Parent::notifier()->id(second))] = val; 490 490 } 491 491 … … 505 505 506 506 virtual void add(const Key& key) { 507 if (size(Parent:: getNotifier()->id(key) + 1) >= (int)values.size()) {508 values.resize(size(Parent:: getNotifier()->id(key) + 1));507 if (size(Parent::notifier()->id(key) + 1) >= (int)values.size()) { 508 values.resize(size(Parent::notifier()->id(key) + 1)); 509 509 } 510 510 } … … 513 513 int new_size = 0; 514 514 for (int i = 0; i < (int)keys.size(); ++i) { 515 if (size(Parent:: getNotifier()->id(keys[i]) + 1) >= new_size) {516 new_size = size(Parent:: getNotifier()->id(keys[i]) + 1);515 if (size(Parent::notifier()->id(keys[i]) + 1) >= new_size) { 516 new_size = size(Parent::notifier()->id(keys[i]) + 1); 517 517 } 518 518 } … … 527 527 528 528 virtual void build() { 529 values.resize(size(Parent:: getNotifier()->maxId() + 1));529 values.resize(size(Parent::notifier()->maxId() + 1)); 530 530 } 531 531 … … 802 802 _second_key_proxy(*this) 803 803 { 804 _first_key_proxy.attach(_firstContainer. getNotifier(FirstKey()));805 _second_key_proxy.attach(_secondContainer. getNotifier(SecondKey()));804 _first_key_proxy.attach(_firstContainer.notifier(FirstKey())); 805 _second_key_proxy.attach(_secondContainer.notifier(SecondKey())); 806 806 } 807 807 … … 818 818 _second_key_proxy(*this) 819 819 { 820 _first_key_proxy.attach(_firstContainer. getNotifier(FirstKey()));821 _second_key_proxy.attach(_secondContainer. getNotifier(SecondKey()));820 _first_key_proxy.attach(_firstContainer.notifier(FirstKey())); 821 _second_key_proxy.attach(_secondContainer.notifier(SecondKey())); 822 822 } 823 823 … … 829 829 if(_copy._first_key_proxy.attached() && 830 830 _copy._second_key_proxy.attached()){ 831 _first_key_proxy.attach(*_copy._first_key_proxy. getNotifier());832 _second_key_proxy.attach(*_copy._second_key_proxy. getNotifier());831 _first_key_proxy.attach(*_copy._first_key_proxy.notifier()); 832 _second_key_proxy.attach(*_copy._second_key_proxy.notifier()); 833 833 values = _copy.values; 834 834 } … … 855 855 ///ordered pair. 856 856 Reference operator()(const FirstKey& _first, const SecondKey& _second) { 857 return values[_first_key_proxy. getNotifier()->id(_first)]858 [_second_key_proxy. getNotifier()->id(_second)];857 return values[_first_key_proxy.notifier()->id(_first)] 858 [_second_key_proxy.notifier()->id(_second)]; 859 859 } 860 860 … … 866 866 ConstReference operator()(const FirstKey& _first, 867 867 const SecondKey& _second) const { 868 return values[_first_key_proxy. getNotifier()->id(_first)]869 [_second_key_proxy. getNotifier()->id(_second)];868 return values[_first_key_proxy.notifier()->id(_first)] 869 [_second_key_proxy.notifier()->id(_second)]; 870 870 } 871 871 … … 875 875 void set(const FirstKey& first, const SecondKey& second, 876 876 const Value& value){ 877 values[_first_key_proxy. getNotifier()->id(first)]878 [_second_key_proxy. getNotifier()->id(second)] = value;877 values[_first_key_proxy.notifier()->id(first)] 878 [_second_key_proxy.notifier()->id(second)] = value; 879 879 } 880 880 … … 894 894 checkConcept<concepts::ReadMatrixMap<FirstKey, SecondKey, Value>, CMap>(); 895 895 const typename FirstKeyProxy::Notifier* notifierFirstKey = 896 _first_key_proxy. getNotifier();896 _first_key_proxy.notifier(); 897 897 const typename SecondKeyProxy::Notifier* notifierSecondKey = 898 _second_key_proxy. getNotifier();898 _second_key_proxy.notifier(); 899 899 FirstKey itemFirst; 900 900 SecondKey itemSecond; … … 917 917 void addFirstKey(const FirstKey& firstKey) { 918 918 int size = (int)values.size(); 919 if( _first_key_proxy. getNotifier()->id(firstKey)+1 >= size ){920 values.resize(_first_key_proxy. getNotifier()->id(firstKey)+1);919 if( _first_key_proxy.notifier()->id(firstKey)+1 >= size ){ 920 values.resize(_first_key_proxy.notifier()->id(firstKey)+1); 921 921 if( (int)values[0].size() != 0 ){ 922 922 int innersize = (int)values[0].size(); … … 924 924 (values[i]).resize(innersize); 925 925 } 926 }else if(_second_key_proxy. getNotifier()->maxId() >= 0){927 int innersize = _second_key_proxy. getNotifier()->maxId();926 }else if(_second_key_proxy.notifier()->maxId() >= 0){ 927 int innersize = _second_key_proxy.notifier()->maxId(); 928 928 for(int i = 0; i != (int)values.size(); ++i){ 929 929 values[0].resize(innersize); … … 940 940 int max = values.size() - 1; 941 941 for(int i=0; i != (int)firstKeys.size(); ++i){ 942 int id = _first_key_proxy. getNotifier()->id(firstKeys[i]);942 int id = _first_key_proxy.notifier()->id(firstKeys[i]); 943 943 if(max < id){ 944 944 max = id; … … 953 953 values[i].resize(innersize); 954 954 } 955 }else if(_second_key_proxy. getNotifier()->maxId() >= 0){956 int innersize = _second_key_proxy. getNotifier()->maxId();955 }else if(_second_key_proxy.notifier()->maxId() >= 0){ 956 int innersize = _second_key_proxy.notifier()->maxId(); 957 957 for(int i = 0; i != (int)values.size(); ++i){ 958 958 values[i].resize(innersize); … … 970 970 return; 971 971 } 972 int id = _second_key_proxy. getNotifier()->id(secondKey);972 int id = _second_key_proxy.notifier()->id(secondKey); 973 973 if(id >= (int)values[0].size()){ 974 974 for(int i=0;i!=(int)values.size();++i){ … … 988 988 int max = values[0].size(); 989 989 for(int i = 0; i != (int)secondKeys.size(); ++i){ 990 int id = _second_key_proxy. getNotifier()->id(secondKeys[i]);990 int id = _second_key_proxy.notifier()->id(secondKeys[i]); 991 991 if(max < id){ 992 992 max = id; … … 1005 1005 ///class belongs to the FirstKey type. 1006 1006 void eraseFirstKey(const FirstKey& first) { 1007 int id = _first_key_proxy. getNotifier()->id(first);1007 int id = _first_key_proxy.notifier()->id(first); 1008 1008 for(int i = 0; i != (int)values[id].size(); ++i){ 1009 1009 values[id][i] = Value(); … … 1017 1017 void eraseFirstKeys(const std::vector<FirstKey>& firstKeys) { 1018 1018 for(int j = 0; j != (int)firstKeys.size(); ++j){ 1019 int id = _first_key_proxy. getNotifier()->id(firstKeys[j]);1019 int id = _first_key_proxy.notifier()->id(firstKeys[j]); 1020 1020 for(int i = 0; i != (int)values[id].size(); ++i){ 1021 1021 values[id][i] = Value(); … … 1032 1032 return; 1033 1033 } 1034 int id = _second_key_proxy. getNotifier()->id(second);1034 int id = _second_key_proxy.notifier()->id(second); 1035 1035 for(int i = 0; i != (int)values.size(); ++i){ 1036 1036 values[i][id] = Value(); … … 1047 1047 } 1048 1048 for(int j = 0; j != (int)secondKeys.size(); ++j){ 1049 int id = _second_key_proxy. getNotifier()->id(secondKeys[j]);1049 int id = _second_key_proxy.notifier()->id(secondKeys[j]); 1050 1050 for(int i = 0; i != (int)values.size(); ++i){ 1051 1051 values[i][id] = Value(); … … 1059 1059 ///to the FirstKey or SecondKey type. 1060 1060 void build() { 1061 values.resize(_first_key_proxy. getNotifier()->maxId());1061 values.resize(_first_key_proxy.notifier()->maxId()); 1062 1062 for(int i=0; i!=(int)values.size(); ++i){ 1063 values[i].resize(_second_key_proxy. getNotifier()->maxId());1063 values[i].resize(_second_key_proxy.notifier()->maxId()); 1064 1064 } 1065 1065 }
Note: See TracChangeset
for help on using the changeset viewer.