Changeset 1194 for trunk/lib/Stats.h


Ignore:
Timestamp:
Oct 4, 2010, 1:39:12 AM (11 years ago)
Author:
Peter Johansson
Message:

refs #475. First version using Sparse Vector class. This change is obviously quite invasive and thus the size of this commit is larger than what is preferred. I've tried to limit as much as possible and left optimization and style issues behind with a note 'FIXME'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.h

    r1124 r1194  
    2626
    2727#include "LineTypeParser.h"
     28#include "Vector.h"
    2829
    2930#include <subversion-1/svn_types.h>
     
    5758    /// @brief adding \a n line(s) to \a user from \a revision to the stats
    5859    ///
    59     void add(const std::string& user, const unsigned int& revision,
    60              const LineTypeParser::line_type&, unsigned int n=1);
     60    //    void add(const std::string& user, svn_revnum_t revision,
     61    //       LineTypeParser::line_type, unsigned int n=1);
    6162
    6263    ///
     
    127128    void reset(void);
    128129
     130    /**
     131       set vectors in stats_ to size \a rev
     132    */
     133    void resize(svn_revnum_t rev);
     134
    129135    ///
    130136    /// \return latest revision for whole project
    131137    ///
    132     svn_revnum_t revision(void) const { return revision_; }
     138    svn_revnum_t revision(void) const;
    133139
    134140    /**
     
    146152
    147153  protected:
    148     typedef std::map<std::string, std::vector<unsigned int> > Author2Vector;
     154    typedef std::map<std::string, SumVector> Author2Vector;
    149155    typedef Author2Vector::iterator A2VIter;
    150156    typedef Author2Vector::const_iterator A2VConstIter;
     157
     158    std::vector<Author2Vector> stats_; // from linetype to a2v
     159
     160    /**
     161     */
     162    void add(const std::vector<std::map<std::string, SparseVector> >& data);
    151163
    152164    /**
     
    155167       \see accumulate
    156168     */
    157     void accumulate_stats(svn_revnum_t rev=1);
     169    //    void accumulate_stats(svn_revnum_t rev=1);
    158170    void add_author(std::string);
    159171    void add_authors(std::set<std::string>::const_iterator,
     
    197209    std::set<std::string> authors_;
    198210
    199     const std::vector<unsigned int>& get_vector(const Author2Vector&,
    200                                          std::string user) const;
     211    const SumVector& get_vector(const Author2Vector&,
     212                                const std::string& user) const;
    201213  private:
    202214    /// one liner used in cache file to validate that cache file was
     
    204216    std::string config_code_;
    205217
     218    void add(SumVector& vec, svn_revnum_t rev, unsigned int n);
    206219    /**
    207220       \a vec is resized to revision().
     
    211224       et cetera
    212225     */
    213     void accumulate(std::vector<unsigned int>& vec,
    214                     svn_revnum_t rev=1) const;
    215     void add(std::vector<unsigned int>& vec, unsigned int rev, bool x,
    216              unsigned int n);
     226    //    void accumulate(std::vector<unsigned int>& vec,
     227    //              svn_revnum_t rev=1) const;
     228    //    void add(std::vector<unsigned int>& vec, unsigned int rev, bool x,
     229    //       unsigned int n);
    217230
    218231    /**
     
    231244       called from plot(2)
    232245     */
     246    // FIXME: why should Stats know about plotting?
    233247    void plot(const std::string& basename, const std::string& linetype,
    234248              const std::string& format) const;
     
    237251       called from plot_summary(1)
    238252     */
     253    // FIXME: why should Stats know about plotting?
    239254    void plot_summary(const std::string& basename,
    240255                      const std::string& format) const;
     
    258273       \return the largest largest element in \a v.
    259274    */
    260     virtual unsigned int max_element(const std::vector<unsigned int>& v) const;
     275    virtual unsigned int max_element(const SumVector& v) const;
    261276
    262277    void print(std::ostream& os, const Author2Vector& m) const;
     
    264279    svn_revnum_t revision_; // Should be the latest revision for whole project
    265280    svn_revnum_t last_changed_rev_; // Should be the latest revision for file
    266 
    267     std::vector<Author2Vector> stats_; // from linetype to a2v
    268281
    269282    // using compiler generated copy constructor
Note: See TracChangeset for help on using the changeset viewer.