< prev index next >

src/hotspot/share/utilities/numberSeq.hpp

Print this page

 66   void add(unsigned val) { add((double) val); }
 67   virtual double maximum() const = 0; // maximum element in the sequence
 68   virtual double last() const = 0; // last element added in the sequence
 69 
 70   // the number of elements in the sequence
 71   int num() const { return _num; }
 72   // the sum of the elements in the sequence
 73   double sum() const { return _sum; }
 74 
 75   double avg() const; // the average of the sequence
 76   double variance() const; // the variance of the sequence
 77   double sd() const; // the standard deviation of the sequence
 78 
 79   double davg() const; // decaying average
 80   double dvariance() const; // decaying variance
 81   double dsd() const; // decaying "standard deviation"
 82 
 83   // Debugging/Printing
 84   virtual void dump();
 85   virtual void dump_on(outputStream* s);



 86 };
 87 
 88 class NumberSeq: public AbsSeq {
 89 private:
 90   bool check_nums(NumberSeq* total, int n, NumberSeq** parts);
 91 
 92 protected:
 93   double _last;
 94   double _maximum; // keep track of maximum value
 95 
 96 public:
 97   NumberSeq(double alpha = DEFAULT_ALPHA_VALUE);
 98 
 99   virtual void add(double val);
100   virtual double maximum() const { return _maximum; }
101   virtual double last() const { return _last; }
102 
103   // Debugging/Printing
104   virtual void dump_on(outputStream* s);



105 };
106 
107 class TruncatedSeq: public AbsSeq {
108 private:
109   enum PrivateConstants {
110     DefaultSeqLength = 10
111   };
112   void init();
113 protected:
114   double *_sequence; // buffers the last L elements in the sequence
115   int     _length; // this is L
116   int     _next;   // oldest slot in the array, i.e. next to be overwritten
117 
118 public:
119   // accepts a value for L
120   TruncatedSeq(int length = DefaultSeqLength,
121                double alpha = DEFAULT_ALPHA_VALUE);
122   ~TruncatedSeq();
123   virtual void add(double val);
124   virtual double maximum() const;
125   virtual double last() const; // the last value added to the sequence
126 
127   double oldest() const; // the oldest valid value in the sequence
128   double predict_next() const; // prediction based on linear regression
129 
130   // Debugging/Printing
131   virtual void dump_on(outputStream* s);



132 };
133 
134 #endif // SHARE_UTILITIES_NUMBERSEQ_HPP

 66   void add(unsigned val) { add((double) val); }
 67   virtual double maximum() const = 0; // maximum element in the sequence
 68   virtual double last() const = 0; // last element added in the sequence
 69 
 70   // the number of elements in the sequence
 71   int num() const { return _num; }
 72   // the sum of the elements in the sequence
 73   double sum() const { return _sum; }
 74 
 75   double avg() const; // the average of the sequence
 76   double variance() const; // the variance of the sequence
 77   double sd() const; // the standard deviation of the sequence
 78 
 79   double davg() const; // decaying average
 80   double dvariance() const; // decaying variance
 81   double dsd() const; // decaying "standard deviation"
 82 
 83   // Debugging/Printing
 84   virtual void dump();
 85   virtual void dump_on(outputStream* s);
 86 
 87   // Merge this AbsSeq into seq2, optionally clearing this AbsSeq
 88   void merge(AbsSeq& seq2, bool clear_this = true);
 89 };
 90 
 91 class NumberSeq: public AbsSeq {
 92 private:
 93   bool check_nums(NumberSeq* total, int n, NumberSeq** parts);
 94 
 95 protected:
 96   double _last;
 97   double _maximum; // keep track of maximum value
 98 
 99 public:
100   NumberSeq(double alpha = DEFAULT_ALPHA_VALUE);
101 
102   virtual void add(double val);
103   virtual double maximum() const { return _maximum; }
104   virtual double last() const { return _last; }
105 
106   // Debugging/Printing
107   virtual void dump_on(outputStream* s);
108 
109   // Merge this NumberSeq into seq2, optionally clearing this NumberSeq
110   void merge(NumberSeq& seq2, bool clear_this = true);
111 };
112 
113 class TruncatedSeq: public AbsSeq {
114 private:
115   enum PrivateConstants {
116     DefaultSeqLength = 10
117   };
118   void init();
119 protected:
120   double *_sequence; // buffers the last L elements in the sequence
121   int     _length; // this is L
122   int     _next;   // oldest slot in the array, i.e. next to be overwritten
123 
124 public:
125   // accepts a value for L
126   TruncatedSeq(int length = DefaultSeqLength,
127                double alpha = DEFAULT_ALPHA_VALUE);
128   ~TruncatedSeq();
129   virtual void add(double val);
130   virtual double maximum() const;
131   virtual double last() const; // the last value added to the sequence
132 
133   double oldest() const; // the oldest valid value in the sequence
134   double predict_next() const; // prediction based on linear regression
135 
136   // Debugging/Printing
137   virtual void dump_on(outputStream* s);
138 
139   // Merge this AbsSeq into seq2, optionally clearing this AbsSeq
140   void merge(AbsSeq& seq2, bool clear_this = true);
141 };
142 
143 #endif // SHARE_UTILITIES_NUMBERSEQ_HPP
< prev index next >