Changeset a07784 in git for Singular/CacheImplementation.h
- Timestamp:
- Dec 5, 2012, 4:03:45 PM (11 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- ae900ff750a6fe0dbab70a5aa87cc48fc3dd280e
- Parents:
- b3646035aca6a8d660df952d443268649a51090907ff965ddd552fe3a981f417b2da928dca53a8f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/CacheImplementation.h
rb36460 ra07784 1 1 #ifndef CACHE_IMPLEMENTATION_H 2 2 #define CACHE_IMPLEMENTATION_H 3 4 #include <reporter/reporter.h> 3 5 4 6 #include <cstdio> // for sprintf … … 53 55 { 54 56 _itKey = _key.end(); // referring to past-the-end element in the list 55 typenamelist<KeyClass>::const_iterator itKey;57 typename std::list<KeyClass>::const_iterator itKey; 56 58 _itValue = _value.begin(); 57 59 /* As _key is a sorted list, the following could actually be implemented … … 80 82 thus, getValue has been called although hasKey 81 83 produced no match */ 82 ass ert(false);84 assume(false); 83 85 84 86 return *_itValue; … … 123 125 erasing the last entry which is only implemented for forward 124 126 iterators by std::list. */ 125 list<int>::iterator itRank;127 std::list<int>::iterator itRank; 126 128 for (itRank = _rank.begin(); itRank != _rank.end(); itRank++) { } 127 129 itRank--; /* Now, this forward iterator points to the last list entry. */ … … 132 134 /* now delete entries in _key and _value with index deleteIndex */ 133 135 int k = 0; 134 typename list<KeyClass>::iterator itKey;135 typename list<ValueClass>::iterator itValue = _value.begin();136 typename list<int>::iterator itWeights = _weights.begin();136 typename std::list<KeyClass>::iterator itKey; 137 typename std::list<ValueClass>::iterator itValue = _value.begin(); 138 typename std::list<int>::iterator itWeights = _weights.begin(); 137 139 for (itKey = _key.begin(); itKey != _key.end(); itKey++) 138 140 { … … 176 178 keyWasContained == false */ 177 179 int k = 0; 178 typename list<KeyClass>::iterator itKey;180 typename std::list<KeyClass>::iterator itKey; 179 181 // itOldValue will later only be used in the case keyWasContained == true: */ 180 typename list<ValueClass>::iterator itOldValue = _value.begin();182 typename std::list<ValueClass>::iterator itOldValue = _value.begin(); 181 183 /* itOldWeights will later only be used in the case 182 184 keyWasContained == true */ 183 typename list<int>::iterator itOldWeights = _weights.begin();185 typename std::list<int>::iterator itOldWeights = _weights.begin(); 184 186 for (itKey = _key.begin(); itKey != _key.end(); itKey++) 185 187 { … … 203 205 int newWeight = value.getWeight(); 204 206 k = 0; 205 typename list<ValueClass>::iterator itValue = _value.begin();207 typename std::list<ValueClass>::iterator itValue = _value.begin(); 206 208 for (itValue = _value.begin(); itValue != _value.end(); itValue++) 207 209 { … … 229 231 _rank[oldIndexInRank] == oldIndexInKey, i.e. 230 232 _key[_rank[oldIndexInRank]] == key: */ 231 list<int>::iterator itRank;233 std::list<int>::iterator itRank; 232 234 k = 0; 233 235 for (itRank = _rank.begin(); itRank != _rank.end(); itRank++) … … 306 308 Let's make room for the assignment 307 309 _rank[newIndexInRank] := newIndexInKey: */ 308 list<int>::iterator itRank;310 std::list<int>::iterator itRank; 309 311 for (itRank = _rank.begin(); itRank != _rank.end(); itRank++) 310 312 { … … 323 325 /* let's insert new key and new value at index newIndexInKey: */ 324 326 itValue = _value.begin(); 325 typename list<int>::iterator itWeights = _weights.begin();327 typename std::list<int>::iterator itWeights = _weights.begin(); 326 328 k = 0; 327 329 for (itKey = _key.begin(); itKey != _key.end(); itKey++) … … 344 346 new (key, value)-pair */ 345 347 346 ass ert(_rank.size() == _key.size());347 ass ert(_rank.size() == _value.size());348 assume(_rank.size() == _key.size()); 349 assume(_rank.size() == _value.size()); 348 350 return !result; /* true iff the new (key --> value) pair is 349 351 actually in the cache now */ … … 351 353 352 354 template<class KeyClass, class ValueClass> 353 st ring Cache<KeyClass, ValueClass>::toString() const355 std::string Cache<KeyClass, ValueClass>::toString() const 354 356 { 355 357 char h[10]; 356 st ring s = "Cache:";358 std::string s = "Cache:"; 357 359 s += "\n entries: "; 358 360 sprintf(h, "%d", getNumberOfEntries()); s += h; … … 371 373 int k = 1; 372 374 s += "\n (key --> value) pairs in ascending order of keys:"; 373 typename list<KeyClass>::const_iterator itKey;374 typename list<ValueClass>::const_iterator itValue = _value.begin();375 typename std::list<KeyClass>::const_iterator itKey; 376 typename std::list<ValueClass>::const_iterator itValue = _value.begin(); 375 377 for (itKey = _key.begin(); itKey != _key.end(); itKey++) 376 378 { … … 385 387 } 386 388 s += "\n (key --> value) pairs in descending order of ranks:"; 387 list<int>::const_iterator itRank;389 std::list<int>::const_iterator itRank; 388 390 int r = 1; 389 391 for (itRank = _rank.begin(); itRank != _rank.end(); itRank++) … … 413 415 void Cache<KeyClass, ValueClass>::print() const 414 416 { 415 cout << this->toString();417 PrintS(this->toString().c_str()); 416 418 } 417 419
Note: See TracChangeset
for help on using the changeset viewer.