Refactor trend indicators to use record structs for state management

This commit is contained in:
Miha Kralj
2025-12-10 21:58:45 -05:00
parent cfc54bf1f7
commit e6033638ad
17 changed files with 390 additions and 484 deletions
+4 -3
View File
@@ -65,9 +65,10 @@ public TValue Update(TValue input, bool isNew = true)
### State Management
* Use `RingBuffer` for sliding windows.
* Maintain `_state` and `_p_state` (previous state) variables to support `isNew=false` rollbacks.
* **Resync**: Periodically recalculate running sums to prevent floating-point drift.
* **Scalar State:** Use a `private record struct State` to group all scalar state variables. This ensures value semantics, automatic `IEquatable` implementation, and cleaner rollback logic.
* **State Variables:** Maintain `private State _state;` (current) and `private State _p_state;` (previous valid state).
* **Buffers:** Use `RingBuffer` for sliding windows.
* **Resync:** Periodically recalculate running sums to prevent floating-point drift.
### Dual API Requirement