2 using System.Collections.Generic;
6 namespace DirectOutput.General.Statistics
8 public class SimpleStatistics<ValueType> where ValueType : IComparable
10 public string Name {
get;
set; }
14 List<ValueType> _MaxValues =
new List<ValueType>();
16 public ValueType MaxValue
20 return MaxValues.Max();
24 public List<ValueType> MaxValues
26 get {
return _MaxValues; }
27 private set { _MaxValues = value; }
31 List<ValueType> _MinValues =
new List<ValueType>();
33 public ValueType MinValue
37 return MaxValues.Min();
42 public List<ValueType> MinValues
44 get {
return _MinValues; }
45 private set { _MinValues = value; }
48 long _ValuesCount = 0;
50 public long ValuesCount
52 get {
return _ValuesCount; }
56 private ValueType MaxBoundary;
57 private ValueType MinBoundary;
58 private bool MinMaxBufferFull =
false;
59 public void AddValue(ValueType Value)
62 if (!MinMaxBufferFull)
66 if (MaxValues.Count >9)
68 MaxBoundary = MaxValues.Min();
69 MinBoundary = MinValues.Max();
70 MinMaxBufferFull =
true;
76 if (Value.CompareTo(MaxBoundary)>0)
78 MaxValues.Remove(MaxBoundary);
80 MaxBoundary = MaxValues.Min();
82 if (Value.CompareTo(MinBoundary) <0)
84 MinValues.Remove(MinBoundary);
86 MinBoundary = MinValues.Max();