Changeset a07784 in git for Singular/CacheImplementation.h


Ignore:
Timestamp:
Dec 5, 2012, 4:03:45 PM (11 years ago)
Author:
Alexander Dreyer <adreyer@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
ae900ff750a6fe0dbab70a5aa87cc48fc3dd280e
Parents:
b3646035aca6a8d660df952d443268649a51090907ff965ddd552fe3a981f417b2da928dca53a8f2
Message:
Merge branch 'spielwiese' of github.com:Singular/Sources into spielwiese-pyobject
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/CacheImplementation.h

    rb36460 ra07784  
    11#ifndef CACHE_IMPLEMENTATION_H
    22#define CACHE_IMPLEMENTATION_H
     3
     4#include <reporter/reporter.h>
    35
    46#include <cstdio> // for sprintf
     
    5355{
    5456  _itKey = _key.end(); // referring to past-the-end element in the list
    55   typename list<KeyClass>::const_iterator itKey;
     57   typename std::list<KeyClass>::const_iterator itKey;
    5658  _itValue = _value.begin();
    5759  /* As _key is a sorted list, the following could actually be implemented
     
    8082       thus, getValue has been called although hasKey
    8183       produced no match */
    82     assert(false);
     84    assume(false);
    8385
    8486  return *_itValue;
     
    123125     erasing the last entry which is only implemented for forward
    124126     iterators by std::list. */
    125   list<int>::iterator itRank;
     127   std::list<int>::iterator itRank;
    126128  for (itRank = _rank.begin(); itRank != _rank.end(); itRank++) { }
    127129  itRank--; /* Now, this forward iterator points to the last list entry. */
     
    132134  /* now delete entries in _key and _value with index deleteIndex */
    133135  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();
    137139  for (itKey = _key.begin(); itKey != _key.end(); itKey++)
    138140  {
     
    176178                                       keyWasContained == false */
    177179  int k = 0;
    178   typename list<KeyClass>::iterator itKey;
     180  typename std::list<KeyClass>::iterator itKey;
    179181  // 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();
    181183  /* itOldWeights will later only be used in the case
    182184     keyWasContained == true */
    183   typename list<int>::iterator itOldWeights = _weights.begin();
     185  typename std::list<int>::iterator itOldWeights = _weights.begin();
    184186  for (itKey = _key.begin(); itKey != _key.end(); itKey++)
    185187  {
     
    203205  int newWeight = value.getWeight();
    204206  k = 0;
    205   typename list<ValueClass>::iterator itValue = _value.begin();
     207  typename std::list<ValueClass>::iterator itValue = _value.begin();
    206208  for (itValue = _value.begin(); itValue != _value.end(); itValue++)
    207209  {
     
    229231       _rank[oldIndexInRank] == oldIndexInKey, i.e.
    230232       _key[_rank[oldIndexInRank]] == key: */
    231     list<int>::iterator itRank;
     233    std::list<int>::iterator itRank;
    232234    k = 0;
    233235    for (itRank = _rank.begin(); itRank != _rank.end(); itRank++)
     
    306308       Let's make room for the assignment
    307309       _rank[newIndexInRank] := newIndexInKey: */
    308     list<int>::iterator itRank;
     310    std::list<int>::iterator itRank;
    309311    for (itRank = _rank.begin(); itRank != _rank.end(); itRank++)
    310312    {
     
    323325    /* let's insert new key and new value at index newIndexInKey: */
    324326    itValue = _value.begin();
    325     typename list<int>::iterator itWeights = _weights.begin();
     327    typename std::list<int>::iterator itWeights = _weights.begin();
    326328    k = 0;
    327329    for (itKey = _key.begin(); itKey != _key.end(); itKey++)
     
    344346                                 new (key, value)-pair */
    345347
    346   assert(_rank.size() == _key.size());
    347   assert(_rank.size() == _value.size());
     348  assume(_rank.size() == _key.size());
     349  assume(_rank.size() == _value.size());
    348350  return !result; /* true iff the new (key --> value) pair is
    349351                     actually in the cache now */
     
    351353
    352354template<class KeyClass, class ValueClass>
    353 string Cache<KeyClass, ValueClass>::toString() const
     355std::string Cache<KeyClass, ValueClass>::toString() const
    354356{
    355357  char h[10];
    356   string s = "Cache:";
     358  std::string s = "Cache:";
    357359  s += "\n   entries: ";
    358360  sprintf(h, "%d", getNumberOfEntries()); s += h;
     
    371373    int k = 1;
    372374    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();
    375377    for (itKey = _key.begin(); itKey != _key.end(); itKey++)
    376378    {
     
    385387    }
    386388    s += "\n   (key --> value) pairs in descending order of ranks:";
    387     list<int>::const_iterator itRank;
     389    std::list<int>::const_iterator itRank;
    388390    int r = 1;
    389391    for (itRank = _rank.begin(); itRank != _rank.end(); itRank++)
     
    413415void Cache<KeyClass, ValueClass>::print() const
    414416{
    415   cout << this->toString();
     417  PrintS(this->toString().c_str());
    416418}
    417419
Note: See TracChangeset for help on using the changeset viewer.