00001 00012 /* 00013 00014 Copyright (c) 2007, Tim Burrell 00015 Initial version Copyright (c) 2005, Alexander Kroeller 00016 00017 Licensed under the Apache License, Version 2.0 (the "License"); 00018 you may not use this file except in compliance with the License. 00019 You may obtain a copy of the License at 00020 00021 http://www.apache.org/licenses/LICENSE-2.0 00022 00023 Unless required by applicable law or agreed to in writing, software 00024 distributed under the License is distributed on an "AS IS" BASIS, 00025 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00026 See the License for the specific language governing permissions and 00027 limitations under the License. 00028 00029 */ 00030 00031 #ifndef __Average_h 00032 #define __Average_h 00033 00034 #if HAVE_CONFIG_H 00035 #include "config.h" 00036 #endif 00037 00038 #include <vector> 00039 00041 // Namespace 00043 00051 namespace H { 00052 00054 // Class Definition 00056 00061 class Average { 00062 public: 00063 // public functions 00064 void push(double Value); 00065 double average(); 00066 00067 // construct / deconstruction 00068 Average(int Size = 10); 00069 virtual ~Average(); 00070 00071 private: 00072 // private member variables 00073 std::vector<double> mValues; 00074 size_t mHeadIdx; 00075 double mSum; 00076 size_t mFillState; 00077 }; 00078 00080 00081 } // H namespace 00082 00083 #endif // __Average_h 00084