]> git.mxchange.org Git - simgear.git/blob - simgear/structure/SGSmplhist.hxx
d56d66930422103940d0ff53a43a5011e20c7273
[simgear.git] / simgear / structure / SGSmplhist.hxx
1 // This may look like C code, but it is really -*- C++ -*-
2 /* 
3 Copyright (C) 1988 Free Software Foundation
4     written by Dirk Grunwald (grunwald@cs.uiuc.edu)
5
6 This file is part of the GNU C++ Library.  This library is free
7 software; you can redistribute it and/or modify it under the terms of
8 the GNU Library General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.  This library is distributed in the hope
11 that it will be useful, but WITHOUT ANY WARRANTY; without even the
12 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE.  See the GNU Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #ifdef HAVE_CONFIG_H
20 #include <simgear_config.h>
21 #endif
22 #ifndef SampleHistogram_h
23 #ifdef __GNUG__
24 #pragma interface
25 #endif
26 #define SampleHistogram_h 1
27
28 #include <iostream>
29 #include <fstream>
30 #include "SGSmplstat.hxx"
31
32 using namespace std;
33
34 extern const int SampleHistogramMinimum;
35 extern const int SampleHistogramMaximum;
36
37 class SampleHistogram:public SampleStatistic
38 {
39 protected:
40   short howManyBuckets;
41   int *bucketCount;
42   double *bucketLimit;
43
44 public:
45
46     SampleHistogram (double low, double hi, double bucketWidth = -1.0);
47
48    ~SampleHistogram ();
49
50   virtual void reset ();
51   virtual void operator += (double);
52
53   int similarSamples (double);
54
55   int buckets ();
56
57   double bucketThreshold (int i);
58   int inBucket (int i);
59   void printBuckets (ostream &);
60
61 };
62
63
64 inline int SampleHistogram::buckets ()
65 {
66   return (howManyBuckets);
67 };
68
69 inline double SampleHistogram::bucketThreshold (int i)
70 {
71   if (i < 0 || i >= howManyBuckets)
72     error ("invalid bucket access");
73   return (bucketLimit[i]);
74 }
75
76 inline int SampleHistogram::inBucket (int i)
77 {
78   if (i < 0 || i >= howManyBuckets)
79     error ("invalid bucket access");
80   return (bucketCount[i]);
81 }
82
83 #endif