Changeset 14 for trunk/lib/Node.cc


Ignore:
Timestamp:
Dec 30, 2005, 3:57:47 PM (16 years ago)
Author:
Peter Johansson
Message:

adding Stats class and removed pointer from node to its mother(dir), which enforced some changes here and there

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Node.cc

    r13 r14  
    1212namespace theplu{
    1313namespace svnstat{
    14 
    15   std::vector<u_int> Node::accumulated(void) const
    16   {
    17     std::vector<u_int> sum(revision_,0);
    18     if (stats_.empty())
    19       return sum;
    20 
    21     // sum of all users
    22     sum = std::accumulate(stats_.begin(),stats_.end(), sum,
    23         VectorPlus<std::string,u_int>());
    24 
    25     // calculate accumulated sum
    26     std::vector<u_int> accum(sum.size());
    27     std::partial_sum(sum.begin(),sum.end(),accum.begin());   
    28     return accum;
    29   }
    30 
    31   std::vector<u_int> Node::accumulated(const std::string& user)
    32   {
    33     std::vector<u_int> vec=stats_[user];
    34     if (vec.empty())
    35       return vec;
    36     std::vector<u_int> accum(vec.size());
    37     std::partial_sum(vec.begin(),vec.end(),accum.begin());
    38     return accum;
    39   }
    40 
    41   void Node::add(const std::string& user, const u_int& rev)
    42   {
    43     std::vector<u_int> vec = stats_[user];
    44     if (vec.size() < rev+1){
    45       u_int i=vec.size();
    46       vec.resize(rev+1);
    47       for (; i<rev; i++)
    48         vec[i]=0;
    49       vec[rev]=1;
    50     }
    51     else
    52       vec[rev]++;
    53     stats_[user]=vec;
    54   }
    5514
    5615  bool Node::info()
Note: See TracChangeset for help on using the changeset viewer.