00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef HxHistoList_h
00010 #define HxHistoList_h
00011
00012 #include <list>
00013
00014 #include "HxHistogram.h"
00015
00016 class HxHistoList {
00017 public:
00018 typedef std::list<HxHistogram>::const_iterator const_iterator;
00019 typedef std::list<HxHistogram>::iterator iterator;
00020
00022 HxHistoList();
00023 HxHistoList(HxHistogram e);
00024 HxHistoList(HxHistogram e1, HxHistogram e2);
00025 HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3);
00026 HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00027 HxHistogram e4);
00028 HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00029 HxHistogram e4, HxHistogram e5);
00030
00031
00032
00034 HxHistoList(const HxHistoList& l);
00035
00037 ~HxHistoList();
00038
00039 HxHistoList& operator=(const HxHistoList& l);
00040
00042 int size() const;
00043 iterator begin();
00044 iterator end();
00045 const_iterator begin() const;
00046 const_iterator end() const;
00047
00048
00049 friend HxHistoList operator+(HxHistoList l, HxHistogram& e);
00050 friend HxHistoList operator+(HxHistogram& e, HxHistoList l);
00051 friend HxHistoList operator+(HxHistoList& e, HxHistoList& l);
00052 void operator+=(HxHistogram& e);
00053
00054 double intersection(HxHistoList& l);
00055 HxHistoList normalize(double weight = 1.0);
00056
00057 private:
00058 std::list<HxHistogram> _hists;
00059 };
00060
00061 inline
00062 HxHistoList::HxHistoList()
00063 {
00064 }
00065
00066 inline
00067 HxHistoList::HxHistoList(HxHistogram e)
00068 {
00069 _hists.push_back(e);
00070 }
00071
00072 inline
00073 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2)
00074 {
00075 _hists.push_back(e1);
00076 _hists.push_back(e2);
00077 }
00078
00079 inline
00080 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3)
00081 {
00082 _hists.push_back(e1);
00083 _hists.push_back(e2);
00084 _hists.push_back(e3);
00085 }
00086
00087 inline
00088 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00089 HxHistogram e4)
00090 {
00091 _hists.push_back(e1);
00092 _hists.push_back(e2);
00093 _hists.push_back(e3);
00094 _hists.push_back(e4);
00095 }
00096
00097 inline
00098 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00099 HxHistogram e4, HxHistogram e5)
00100 {
00101 _hists.push_back(e1);
00102 _hists.push_back(e2);
00103 _hists.push_back(e3);
00104 _hists.push_back(e4);
00105 _hists.push_back(e5);
00106 }
00107
00108 inline
00109 HxHistoList::HxHistoList(const HxHistoList& l)
00110 {
00111 _hists = l._hists;
00112 }
00113
00114 inline
00115 HxHistoList::~HxHistoList()
00116 {
00117 }
00118
00119 inline HxHistoList&
00120 HxHistoList::operator=(const HxHistoList& l)
00121 {
00122 if (&l != this)
00123 _hists = l._hists;
00124 return *this;
00125 }
00126
00127 inline int
00128 HxHistoList::size() const
00129 {
00130 return _hists.size();
00131 }
00132
00133 inline HxHistoList::iterator
00134 HxHistoList::begin()
00135 {
00136 return _hists.begin();
00137 }
00138
00139 inline HxHistoList::iterator
00140 HxHistoList::end()
00141 {
00142 return _hists.end();
00143 }
00144
00145 inline HxHistoList::const_iterator
00146 HxHistoList::begin() const
00147 {
00148 return _hists.begin();
00149 }
00150
00151 inline HxHistoList::const_iterator
00152 HxHistoList::end() const
00153 {
00154 return _hists.end();
00155 }
00156
00157 inline double
00158 HxHistoList::intersection(HxHistoList& l)
00159 {
00160 HxHistoList::iterator i;
00161 HxHistoList::iterator j;
00162 double res = 0.0;
00163 int n = 0;
00164
00165 for (i = begin(), j = l.begin();
00166 (i != end()) && (j != l.end()); i++, j++) {
00167 res += (*i).intersection(*j);
00168 n++;
00169 }
00170 if (n)
00171 res /= n;
00172
00173 return res;
00174 }
00175
00176 inline HxHistoList
00177 HxHistoList::normalize(double weight)
00178 {
00179 HxHistoList::iterator i;
00180 HxHistoList l;
00181
00182 for (i = _hists.begin(); i != _hists.end(); i++) {
00183 HxHistogram h = (*i).normalize(weight);
00184 l += h;
00185 }
00186
00187 return l;
00188 }
00189
00190
00191 inline HxHistoList
00192 operator+(HxHistoList l, HxHistogram& e)
00193 {
00194 l._hists.push_back(e);
00195 return l;
00196 }
00197
00198 inline HxHistoList
00199 operator+(HxHistogram& e, HxHistoList l)
00200 {
00201 l._hists.push_front(e);
00202 return l;
00203 }
00204
00205 inline void
00206 HxHistoList::operator+=(HxHistogram& e)
00207 {
00208 _hists.push_back(e);
00209 }
00210
00211 inline HxHistoList
00212 operator+(HxHistoList& e, HxHistoList& l)
00213 {
00214 HxHistoList n;
00215 HxHistoList::const_iterator i;
00216
00217 for (i = e._hists.begin(); i != e._hists.end(); i++)
00218 n._hists.push_back(*i);
00219 for (i = l._hists.begin(); i != l._hists.end(); i++)
00220 n._hists.push_back(*i);
00221
00222 return n;
00223 }
00224
00225 HxHistoList operator+(HxHistoList l, HxHistogram& e);
00226 HxHistoList operator+(HxHistogram& e, HxHistoList l);
00227 HxHistoList operator+(HxHistoList& e, HxHistoList& l);
00228
00229 #endif