multi-resolution-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 
00008 #ifndef HISTOGRAMS_MULTI_RESOLUTION_HISTOGRAM_H
00009 #define HISTOGRAMS_MULTI_RESOLUTION_HISTOGRAM_H
00010 
00011 #include <iostream>
00012 #include "histograms/bin.h"
00013 #include "util/tree.cc"
00014 
00015 using namespace std;
00016 
00017 namespace libpmk {
00018 template class Tree<Bin>;
00019 
00022 
00028 class MultiResolutionHistogram {
00029  public:
00030    MultiResolutionHistogram() { }
00031 
00032    int GetNumLevels() const;
00033    int GetNumBins() const;
00034 
00036 
00039    Bin* GetBin(LargeIndex index);
00040 
00042 
00047    Bin* GetBin(LargeIndex index, Bin* finger);
00048 
00050    Bin* GetRootBin();
00051    Bin* const GetRootBin() const;
00052 
00054 
00071    Bin* AddBin(const Bin& new_bin);
00072 
00073    // Same as AddBin(), except if the user already has a pointer to the
00074    // parent, use that. If the parent is invalid, NULL is returned and 
00075    // no bin is added. In order for this to work properly, the parent pointer
00076    // MUST be a bin which can be accessed through child pointers of
00077    // root_bin_. In other words, this MultiResolutionHistogram must be the
00078    // owner of the parent that you pass into it. We do NOT check for this;
00079    // it is up to the client to make sure of it.
00081 
00087    Bin* AddBin(const Bin& new_bin, Bin* finger);
00088 
00090    void DeleteBin(Bin* finger);
00091 
00093 
00100    static vector<MultiResolutionHistogram*>
00101       ReadFromStream(istream& input_stream);
00102    
00104 
00107    static vector<MultiResolutionHistogram*>
00108       ReadFromFile(const char* filename);
00109 
00111 
00122    static vector<MultiResolutionHistogram*>
00123       ReadSelectionFromStream(istream& input_stream,
00124                               int start, int selection_size);
00125 
00127 
00130    static vector<MultiResolutionHistogram*>
00131       ReadSelectionFromFile(const char* filename, int start,
00132                             int selection_size);
00134 
00138    static void WriteToStream(ostream& output_stream,
00139                              const vector<MultiResolutionHistogram*>& hists);
00140 
00142 
00145    static void WriteToFile(const char* filename,
00146                            const vector<MultiResolutionHistogram*>& hists);
00147 
00149 
00162    static MultiResolutionHistogram*
00163       ReadSingleHistogramFromStream(istream& input_stream);
00164 
00166    static void IgnoreSingleHistogramFromStream(istream& input_stream);
00167    
00169 
00173    static void WriteSingleHistogramToStream(ostream& output_stream,
00174                                             const MultiResolutionHistogram* h);
00175    
00176  private:
00177    Tree<Bin> tree_;   
00178 }; 
00179 }  // namespace libpmk
00180 #endif  // HISTOGRAMS_MULTI_RESOLUTION_HISTOGRAM_H

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