Changeset 23 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Jan 2, 2006, 9:14:57 AM (16 years ago)
Author:
Peter Johansson
Message:

added print functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r14 r23  
    77#include <numeric>
    88#include <string>
     9#include <utility>
    910#include <vector>
     11
     12#include <iostream>
    1013
    1114namespace theplu{
     
    5962  }
    6063
     64  void Stats::print(std::ostream& os) const
     65  {
     66    std::vector<std::pair<std::string, std::vector<u_int> > > accum;
     67    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++){
     68      std::pair<std::string, std::vector<u_int> > element(*i);
     69      std::partial_sum(element.second.begin(),element.second.end(),
     70                       element.second.begin());
     71      accum.push_back(element);
     72    }
     73    sort(accum.begin(),accum.end(), CodingMore());
     74    os << "<table>\n";
     75    for (size_t i = 0; i<accum.size(); i++){
     76      os << "<tr><td>\n" << accum[i].first << "</td><td>"
     77         << accum[i].second.back() << "</td></tr>";
     78    }
     79    os << "</table>\n";
     80
     81    os << "<p>[Plot to be here.]</p>\n";         
     82  }
     83
    6184  Stats& Stats::operator+=(const Stats& other)
    6285  {
    63     for (_MapConstIt o_i= other.map_.begin(); o_i != other.map_.end(); ++o_i)
     86    for (MapConstIter_ o_i= other.map_.begin(); o_i != other.map_.end(); ++o_i)
    6487    {
    65       std::pair<_MapIt,bool> result = map_.insert(*o_i);
     88      std::pair<MapIter_,bool> result = map_.insert(*o_i);
    6689      if (!result.second)
    67   map_[(*(result.first)).first] =
    68     VectorPlus<u_int>()( (*(result.first)).second, (*o_i).second );
     90        map_[(*(result.first)).first] =
     91          VectorPlus<u_int>()( (*(result.first)).second, (*o_i).second );
    6992 
    7093    }
Note: See TracChangeset for help on using the changeset viewer.