00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef PATHFIND_STATISTICS_H
00011 #define PATHFIND_STATISTICS_H
00012
00013 #include <iostream>
00014 #include <math.h>
00015 #include <map>
00016 #include <string>
00017
00018
00019
00020 namespace PathFind
00021 {
00022 using namespace std;
00023
00024
00025 class Statistics
00026 {
00027 public:
00028 Statistics();
00029
00030 void add(double value);
00031
00032 void add(const Statistics& statistics);
00033
00034 void clear();
00035
00036 double getCount() const
00037 {
00038 return m_count;
00039 }
00040
00041 double getMean() const
00042 {
00043 return m_sum / m_count;
00044 }
00045
00046 double getDeviation() const
00047 {
00048 return sqrt(getVariance());
00049 }
00050
00051 double getVariance() const;
00052
00053 void print(ostream& o) const;
00054
00055 private:
00056 double m_count;
00057
00058 double m_sum;
00059
00060 double m_sumSq;
00061 };
00062
00063
00064 class StatisticsCollection
00065 {
00066 public:
00067
00068
00069
00070 void add(const StatisticsCollection& collection);
00071
00072 void clear();
00073
00074 void create(const string& name);
00075
00076 const Statistics& get(const string& name) const;
00077
00078 Statistics& get(const string& name);
00079
00080 void print(ostream& o) const;
00081
00082 private:
00083 map<string, Statistics> m_map;
00084 };
00085 }
00086
00087
00088
00089 #endif