00001
00002
00003
00004
00005
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
00074
00075
00076
00077
00078
00079
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 }
00180 #endif // HISTOGRAMS_MULTI_RESOLUTION_HISTOGRAM_H