]> git.mxchange.org Git - simgear.git/blob - simgear/structure/SGSmplhist.hxx
std:: namespace fixes, and sink some code from the subsystem header into the implemen...
[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 #ifndef SampleHistogram_h
20 #define SampleHistogram_h 1
21
22 #include <iosfwd>
23 #include "SGSmplstat.hxx"
24
25 extern const int SampleHistogramMinimum;
26 extern const int SampleHistogramMaximum;
27
28 class SampleHistogram:public SampleStatistic
29 {
30 protected:
31   short howManyBuckets;
32   int *bucketCount;
33   double *bucketLimit;
34
35 public:
36
37     SampleHistogram (double low, double hi, double bucketWidth = -1.0);
38
39    ~SampleHistogram ();
40
41   virtual void reset ();
42   virtual void operator += (double);
43
44   int similarSamples (double);
45
46   int buckets ();
47
48   double bucketThreshold (int i);
49   int inBucket (int i);
50   void printBuckets (std::ostream &);
51
52 };
53
54
55 inline int SampleHistogram::buckets ()
56 {
57   return (howManyBuckets);
58 };
59
60 inline double SampleHistogram::bucketThreshold (int i)
61 {
62   if (i < 0 || i >= howManyBuckets)
63     error ("invalid bucket access");
64   return (bucketLimit[i]);
65 }
66
67 inline int SampleHistogram::inBucket (int i)
68 {
69   if (i < 0 || i >= howManyBuckets)
70     error ("invalid bucket access");
71   return (bucketCount[i]);
72 }
73
74 #endif