It can be used to count how many elements of type T, from a source of input,
fall into certain bins.
Iterators providing access to the elements of a Histogram are all read-only.
Dereferencing an iterator yields a type
'const std::pair<unsigned int, unsigned int>' where 'first' is the number
of the bin, and 'second' in the number of times an element fell into the bin.
value_type |
The type of object that are being counted. |
const_iterator |
A read-only iterator that passes over all non-empty bins. |
const_reverse_iterator |
A read-only iterator that passes over all non-empty bins. |
Histogram(const unsigned nrBins =
std::numeric_limits<unsigned>::max(),
const value_type minValue = value_type(0),
const value_type maxValue =
std::numeric_limits<value_type>::max()) |
Default constructor, by default, the number of bins is
std::numeric_limits<unsigned>::max(), minValue is zero
and maxValue is
std::numeric_limits<unsigned>::max(). |
template <typename InputIterator>
Histogram(const InputIterator first, const InputIterator last,
const unsigned nrBins,
const value_type minValue = value_type(0),
const value_type maxValue =
std::numeric_limits<value_type>::max()) |
Constructs a Histogram, and fills it based on the input given
by InputIterator first and last. |
unsigned size() const |
Returns the number of non-empty bins. |
unsigned maxSize() const |
Returns the maximum number of non-empty bins, i.e. the largest
value that size() can return. |
unsigned elements() const |
The number of elements that has been inserted, or the sum of
all bins. |
const_iterator
atLeastPercentGreater(const double percentElements) const |
Given a number between 0.0 and 1.0, returns an iterator
to the lowest bin in the histogram such that dataPercent percent
of the data is in bins lower than the returned element. |
const_iterator atLeastGreater(const unsigned elements) const |
Returns an iterator to a bin such that the sum of the previous
bins at least equals elements. |
const_reverse_iterator
atMostPercentGreater(const double percentElements) const |
Given a number between 0.0 and 1.0, returns an iterator to the
highest bin in the histogram such that percentElements percent of
the data is in bins higher than the returned element. |
const_reverse_iterator
atMostGreater(const unsigned elements) const |
Returns an iterator to a bin such that there are at least
elements in the bins higher than the returned bin. |
double binSize() const |
Return the 'width' of one bin. |
void clear() |
Remove all data from the Histogram. |
void insert(const value_type &value) |
Insert value. |
template <typename InputIterator>
void insert(const InputIterator first, const InputIterator last) |
Insert all elements in the range first to last. |
template <typename InputIterator, class UnaryFunction>
void insert(const InputIterator first, const InputIterator last,
UnaryFunction op) |
For all elements in the range first to last: apply
op, then insert. |
float operator()(const unsigned bin) const |
The fraction of the all the elements that are in bin. |
const_iterator begin() |
A const_iterator: begin. |
const_iterator end() |
A const_iterator: end. |
const_reverse_iterator rbegin() |
A const_reverse-iterator: begin. |
const_reverse_iterator rend() |
A const_reverse-iterator: end. |
double avg() const |
The average value of the non-empty bins. |
Histogram &operator+=(const Histogram &rhs) |
Merge the results in another Histogram. |