Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
stat
histogram.h
Go to the documentation of this file.
1
/* histogram.h
2
*/
3
#ifndef _HISTOGRAM_H
4
#define _HISTOGRAM_H
5
6
#include <boost/scoped_array.hpp>
7
#include <iosfwd>
8
namespace
osl
9
{
10
namespace
stat
11
{
15
class
Histogram
16
{
17
boost::scoped_array<double>
data
;
18
size_t
length_
,
width_
;
19
int
start_
;
20
bool
show_on_destruct
;
21
public
:
22
Histogram
(
size_t
w,
size_t
len,
int
start
=0,
bool
show_on_destruct
=
false
);
23
~Histogram
();
24
size_t
safeIndex
(
size_t
i)
const
25
{
26
return
(i >=
length_
) ?
length_
-1 : i;
27
}
28
double
&
frequency
(
size_t
i) {
return
data
[
safeIndex
(i)]; }
29
void
add
(
int
value,
double
weight
=1.0)
30
{
31
if
(value <
start_
)
32
value = 0;
33
else
34
value -=
start_
;
35
frequency
(value/
width_
) +=
weight
;
36
}
37
double
frequency
(
size_t
i)
const
{
return
data
[
safeIndex
(i)]; }
38
void
show
(std::ostream& os)
const
;
39
40
size_t
length
()
const
{
return
length_
; }
41
size_t
width
()
const
{
return
width_
; }
42
int
start
()
const
{
return
start_
; }
43
45
void
merge
(
const
Histogram
&);
47
void
showRatio
(std::ostream& os,
const
Histogram
& numerator)
const
;
48
};
49
}
// namespace stat
50
using
stat::Histogram;
51
}
// namespace osl
52
53
#endif
/* _HISTOGRAM_H */
54
// ;;; Local Variables:
55
// ;;; mode:c++
56
// ;;; c-basic-offset:2
57
// ;;; End:
Generated on Sun Jul 21 2013 13:37:24 by
1.8.4