fix: address code review issues in indicators and core components

This commit is contained in:
Miha Kralj
2025-12-09 16:00:04 -05:00
parent 5e6e3a070e
commit c802a9ea80
12 changed files with 54 additions and 26 deletions
+16
View File
@@ -82,6 +82,22 @@ public sealed class RingBuffer : IEnumerable<double>
get => _sum;
}
/// <summary>
/// Recalculates the sum by iterating over all elements.
/// Useful for correcting floating-point drift after many updates.
/// </summary>
public double RecalculateSum()
{
double sum = 0;
var span = GetSpan();
for (int i = 0; i < span.Length; i++)
{
sum += span[i];
}
_sum = sum;
return sum;
}
/// <summary>
/// Average of all elements in the buffer.
/// Returns 0 if buffer is empty.