00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 #include <simgear_config.h>
00021 #endif
00022 #ifndef SampleHistogram_h
00023 #ifdef __GNUG__
00024 #pragma interface
00025 #endif
00026 #define SampleHistogram_h 1
00027
00028 #include <iosfwd>
00029 #include "SGSmplstat.hxx"
00030
00031 extern const int SampleHistogramMinimum;
00032 extern const int SampleHistogramMaximum;
00033
00034 class SampleHistogram:public SampleStatistic
00035 {
00036 protected:
00037 short howManyBuckets;
00038 int *bucketCount;
00039 double *bucketLimit;
00040
00041 public:
00042
00043 SampleHistogram (double low, double hi, double bucketWidth = -1.0);
00044
00045 ~SampleHistogram ();
00046
00047 virtual void reset ();
00048 virtual void operator += (double);
00049
00050 int similarSamples (double);
00051
00052 int buckets ();
00053
00054 double bucketThreshold (int i);
00055 int inBucket (int i);
00056 void printBuckets (std::ostream &);
00057
00058 };
00059
00060
00061 inline int SampleHistogram::buckets ()
00062 {
00063 return (howManyBuckets);
00064 };
00065
00066 inline double SampleHistogram::bucketThreshold (int i)
00067 {
00068 if (i < 0 || i >= howManyBuckets)
00069 error ("invalid bucket access");
00070 return (bucketLimit[i]);
00071 }
00072
00073 inline int SampleHistogram::inBucket (int i)
00074 {
00075 if (i < 0 || i >= howManyBuckets)
00076 error ("invalid bucket access");
00077 return (bucketCount[i]);
00078 }
00079
00080 #endif