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 "tree/sparse-tree.cc"
00014
00015 using namespace std;
00016
00017 namespace libpmk {
00018 template class SparseTree<Bin>;
00019
00022
00028 class MultiResolutionHistogram {
00029 public:
00030 MultiResolutionHistogram() { }
00031
00032 int size() const { return tree_.size(); }
00033
00035
00038 Bin* bin(LargeIndex index);
00039
00041
00046 Bin* bin(LargeIndex index, Bin* finger);
00047
00049 Bin* root() { return tree_.root(); }
00050 Bin* const root() const { return tree_.root(); }
00051
00053
00070 Bin* add_bin(const Bin& new_bin);
00071
00072
00073
00074
00075
00076
00077
00078
00080
00086 Bin* add_bin(const Bin& new_bin, Bin* finger);
00087
00089 void remove_bin(Bin* finger);
00090
00092
00099 static vector<MultiResolutionHistogram*>
00100 ReadFromStream(istream& input_stream);
00101
00103
00106 static vector<MultiResolutionHistogram*>
00107 ReadFromFile(const char* filename);
00108
00110
00121 static vector<MultiResolutionHistogram*>
00122 ReadSelectionFromStream(istream& input_stream,
00123 int start, int selection_size);
00124
00126
00129 static vector<MultiResolutionHistogram*>
00130 ReadSelectionFromFile(const char* filename, int start,
00131 int selection_size);
00133
00137 static void WriteToStream(ostream& output_stream,
00138 const vector<MultiResolutionHistogram*>& hists);
00139
00141
00144 static void WriteToFile(const char* filename,
00145 const vector<MultiResolutionHistogram*>& hists);
00146
00148
00161 static MultiResolutionHistogram*
00162 ReadSingleHistogramFromStream(istream& input_stream);
00163
00165 static void IgnoreSingleHistogramFromStream(istream& input_stream);
00166
00168
00172 static void WriteSingleHistogramToStream(ostream& output_stream,
00173 const MultiResolutionHistogram* h);
00174
00175 private:
00176 SparseTree<Bin> tree_;
00177 };
00178 }
00179 #endif // HISTOGRAMS_MULTI_RESOLUTION_HISTOGRAM_H