A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
histogram.h
Go to the documentation of this file.
1//
2// Copyright (c) 2009 INESC Porto
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: Pedro Fortuna <pedro.fortuna@inescporto.pt> <pedro.fortuna@gmail.com>
18//
19
20#ifndef NS3_HISTOGRAM_H
21#define NS3_HISTOGRAM_H
22
23#include <ostream>
24#include <stdint.h>
25#include <vector>
26
27namespace ns3
28{
29
46{
47 public:
48 // --- basic methods ---
53 Histogram(double binWidth);
54 Histogram();
55
56 // Methods for Getting the Histogram Results
61 uint32_t GetNBins() const;
67 double GetBinStart(uint32_t index) const;
73 double GetBinEnd(uint32_t index) const;
82 double GetBinWidth(uint32_t index) const;
90 void SetDefaultBinWidth(double binWidth);
96 uint32_t GetBinCount(uint32_t index) const;
97
98 // Method for adding values
103 void AddValue(double value);
104
108 void Clear();
109
116 void SerializeToXmlStream(std::ostream& os, uint16_t indent, std::string elementName) const;
117
118 private:
119 std::vector<uint32_t> m_histogram;
120 double m_binWidth;
121};
122
123} // namespace ns3
124
125#endif /* NS3_HISTOGRAM_H */
Class used to store data and make an histogram of the data frequency.
Definition: histogram.h:46
void Clear()
Clear the histogram content.
Definition: histogram.cc:96
double GetBinWidth(uint32_t index) const
Returns the bin width.
Definition: histogram.cc:61
uint32_t GetBinCount(uint32_t index) const
Get the number of data added to the bin.
Definition: histogram.cc:74
std::vector< uint32_t > m_histogram
Histogram data.
Definition: histogram.h:119
void SetDefaultBinWidth(double binWidth)
Set the bin width.
Definition: histogram.cc:67
double m_binWidth
Bin width.
Definition: histogram.h:120
uint32_t GetNBins() const
Returns the number of bins in the histogram.
Definition: histogram.cc:43
void SerializeToXmlStream(std::ostream &os, uint16_t indent, std::string elementName) const
Serializes the results to an std::ostream in XML format.
Definition: histogram.cc:112
double GetBinEnd(uint32_t index) const
Returns the bin end, i.e., (index+1)*binWidth.
Definition: histogram.cc:55
void AddValue(double value)
Add a value to the histogram.
Definition: histogram.cc:81
double GetBinStart(uint32_t index) const
Returns the bin start, i.e., index*binWidth.
Definition: histogram.cc:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.