histogram.h

Go to the documentation of this file.
00001 // Copyright 2007, Massachusetts Institute of Technology.
00002 // The use of this code is permitted for research only. There is
00003 // absolutely no warranty for this software.
00004 //
00005 // Author: John Lee (jjl@mit.edu)
00006 //
00007 #ifndef HISTOGRAMS_HISTOGRAM_H
00008 #define HISTOGRAMS_HISTOGRAM_H
00009 
00010 #include <string>
00011 #include <iostream>
00012 #include "histograms/bin.h"
00013 
00014 using namespace std;
00015 
00016 namespace libpmk {
00018 
00026 class Histogram {
00027  public:
00028    Histogram();
00029    ~Histogram();
00030 
00032 
00040    Bin* AddBin(const Bin& new_bin);
00041 
00043 
00048    void SortBins() const;
00049 
00051    int GetNumBins() const;
00052 
00054 
00057    const Bin* GetBin(int ii);
00058 
00060 
00063    const Bin* GetBin(const LargeIndex& index);
00064 
00066 
00071    const Bin* GetBin(const LargeIndex& index, int finger);
00072 
00073    // We pass pointers instead of const references, since this function has
00074    // the capability to modify the histograms themselves (by sorting their
00075    // contents).
00077    static double ComputeIntersection(Histogram* first, Histogram* second);
00078 
00080 
00085    static void WriteToStream(ostream& output_stream,
00086                              const vector<Histogram*>& histograms);
00087 
00089 
00101    static void WriteSingleHistogramToStream(ostream& output_stream,
00102                                             Histogram* h);
00103 
00104    
00106 
00112    static vector<Histogram*> ReadFromStream(istream& input_stream);
00113 
00115 
00121    static Histogram* ReadSingleHistogramFromStream(istream& input_stream);
00122 
00123  private:
00124    // Disallow evil constructors
00125    Histogram(const Histogram&);
00126    Histogram& operator=(const Histogram&);
00127 
00128    mutable vector<Bin*> bins_;
00129    mutable bool is_sorted_;
00130 };
00131 }  // namespace libpmk
00132 
00133 #endif  // HISTOGRAMS_HISTOGRAM_H

Generated on Wed May 2 11:17:12 2007 for libpmk by  doxygen 1.5.1