Changeset 1208 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Oct 7, 2010, 5:33:36 AM (12 years ago)
Author:
Peter Johansson
Message:

Changed value type of SparseVector? to be (signed) int. Use
Vector::iterator when printing Vector's data instead of using
operator[]
refs #475

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r1205 r1208  
    556556    for (A2VConstIter i(m.begin()); i!=m.end(); ++i){
    557557      os << i->first << "\n";
    558       if (i->second[0])
    559         os << 0 << " " << i->second[0] << " ";
    560       // FIXME: ise Vector::iterator
    561       for (size_t j=1; j<i->second.size(); ++j) {
    562         // only print if stats changes in this rev
    563         if (i->second[j] != i->second[j-1]) {
    564           os << j << " " << i->second[j] - i->second[j-1] << " ";
     558      const SumVector& vec = i->second;
     559      if (vec.size()) {
     560        SumVector::const_iterator v = vec.begin();
     561        if (v->second)
     562          os << v->first << " " << v->second << " ";
     563        ++v;
     564        SumVector::const_iterator prev = vec.begin();
     565        while (v != vec.end()) {
     566          assert(vec[v->first - 1] == prev->second);
     567          // FIXME: this if should not be needed if SumVector was
     568          // truly sparse and collapsed when possible.
     569          if (v->second != prev->second)
     570            os << v->first << " " << v->second - prev->second << " ";
     571          ++v;
     572          ++prev;
    565573        }
    566574      }
Note: See TracChangeset for help on using the changeset viewer.