OpenWalnut  1.5.0dev
Public Member Functions | Protected Attributes | List of all members
WHistogram Class Referenceabstract

Container which associate values with (uniform width) bins (aka intervals or buckets). More...

#include <WHistogram.h>

+ Inheritance diagram for WHistogram:
+ Collaboration diagram for WHistogram:

Public Member Functions

 WHistogram (double min, double max, std::size_t buckets=1000)
 Default constructor. More...
 
 WHistogram (const WHistogram &hist)
 Copy constructor. More...
 
virtual ~WHistogram ()
 Default destructor. More...
 
virtual std::size_t operator[] (std::size_t index) const =0
 Get the count of the specified bucket. More...
 
virtual std::size_t at (std::size_t index) const =0
 Get the count of the specified bucket. More...
 
virtual std::size_t size () const
 Returns the number of buckets in the histogram with the actual mapping. More...
 
virtual double getMinimum () const
 Returns the minimum value. More...
 
virtual double getMaximum () const
 Returns the maximum value. More...
 
virtual double getBucketSize (std::size_t index=0) const =0
 Return the size of one specific bucket. More...
 
virtual std::pair< double, double > getIntervalForIndex (std::size_t index) const =0
 Returns the actual interval associated with the given index. More...
 

Protected Attributes

double m_minimum
 The smallest value. More...
 
double m_maximum
 The biggest value. More...
 
double m_nbBuckets
 The number of buckets. More...
 

Detailed Description

Container which associate values with (uniform width) bins (aka intervals or buckets).

This class implements the abstract interface and therefore builds the base class for all histogram classes. The interface also allows programming histogram of different bucket sizes.

Definition at line 35 of file WHistogram.h.

Constructor & Destructor Documentation

◆ WHistogram() [1/2]

WHistogram::WHistogram ( double  min,
double  max,
std::size_t  buckets = 1000 
)

Default constructor.

Creates an empty histogram covering the specified min and max values with the specified number of buckets.

Parameters
minthe smallest value
maxthe largest value
bucketsthe number of buckets

Definition at line 30 of file WHistogram.cpp.

References m_maximum, and m_minimum.

◆ WHistogram() [2/2]

WHistogram::WHistogram ( const WHistogram hist)

Copy constructor.

Creates a deep copy of the specified histogram.

Parameters
histthe histogram to copy.

Definition at line 43 of file WHistogram.cpp.

◆ ~WHistogram()

WHistogram::~WHistogram ( )
virtual

Default destructor.

Definition at line 50 of file WHistogram.cpp.

Member Function Documentation

◆ at()

virtual std::size_t WHistogram::at ( std::size_t  index) const
pure virtual

Get the count of the specified bucket.

Testing if the position is valid.

Parameters
indexwhich buckets count is to be returned; starts with 0 which is the bucket containing the smallest values.
Returns
elements in the bucket

Implemented in WHistogramBasic.

◆ getBucketSize()

virtual double WHistogram::getBucketSize ( std::size_t  index = 0) const
pure virtual

Return the size of one specific bucket.

Parameters
indexthe width for this bucket is queried.
Returns
the size of a bucket.

Implemented in WHistogramBasic.

◆ getIntervalForIndex()

virtual std::pair< double, double > WHistogram::getIntervalForIndex ( std::size_t  index) const
pure virtual

Returns the actual interval associated with the given index.

The interval is open, meaning that getIntervalForIndex( i ).second == getIntervalForIndex( i + 1 ).first but does not belong anymore to the interval itself but every value smaller than getIntervalForIndex( i ).second.

Parameters
indexthe intex
Returns
the open interval.

Implemented in WHistogramBasic.

◆ getMaximum()

double WHistogram::getMaximum ( ) const
virtual

Returns the maximum value.

Returns
maximum

Definition at line 64 of file WHistogram.cpp.

References m_maximum.

◆ getMinimum()

double WHistogram::getMinimum ( ) const
virtual

Returns the minimum value.

Returns
minimum

Definition at line 59 of file WHistogram.cpp.

References m_minimum.

◆ operator[]()

virtual std::size_t WHistogram::operator[] ( std::size_t  index) const
pure virtual

Get the count of the specified bucket.

Parameters
indexwhich buckets count is to be returned; starts with 0 which is the bucket containing the smallest values.
Returns
elements in the bucket.

Implemented in WHistogramBasic.

◆ size()

size_t WHistogram::size ( ) const
virtual

Returns the number of buckets in the histogram with the actual mapping.

Returns
number of buckets

Reimplemented in WValueSetHistogram.

Definition at line 54 of file WHistogram.cpp.

References m_nbBuckets.

Referenced by WHistogramBasicTest::testInitialization(), WHistogramBasicTest::testInsert(), WHistogramBasicTest::testInsertOutOfBounds(), and WHistogramBasicTest::testOperatorToGetNumberOfElementsInsideTheBin().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_maximum

double WHistogram::m_maximum
protected

◆ m_minimum

double WHistogram::m_minimum
protected

◆ m_nbBuckets

double WHistogram::m_nbBuckets
protected

The number of buckets.

Definition at line 132 of file WHistogram.h.

Referenced by WValueSetHistogram::buildHistogram(), WHistogramBasic::insert(), and size().


The documentation for this class was generated from the following files: