mirror of
https://github.com/Phantop/LADXHD.git
synced 2024-11-21 22:12:44 +00:00
29 lines
616 B
C#
29 lines
616 B
C#
using System.Linq;
|
|
|
|
namespace ProjectZ.Base
|
|
{
|
|
public class DoubleAverage
|
|
{
|
|
public double Average;
|
|
|
|
private readonly double[] _timeCounts;
|
|
private int _currentIndex;
|
|
|
|
public DoubleAverage(int size)
|
|
{
|
|
_timeCounts = new double[size];
|
|
}
|
|
|
|
public void AddValue(double value)
|
|
{
|
|
_timeCounts[_currentIndex] = value;
|
|
|
|
_currentIndex++;
|
|
if (_currentIndex >= _timeCounts.Length)
|
|
_currentIndex = 0;
|
|
|
|
Average = _timeCounts.Average();
|
|
}
|
|
}
|
|
}
|