golang-moving-average
golang-moving-average copied to clipboard
feat: add reset()
This pull request introduces a new Reset method to both the MovingAverage and ConcurrentMovingAverage classes and adds corresponding unit tests to ensure the functionality works as expected.
Key changes include:
-
New
ResetMethod:ma.go: Added aResetmethod to theMovingAverageclass to reset its internal state.ma_concurrent.go: Added aResetmethod to theConcurrentMovingAverageclass, ensuring thread safety by locking and unlocking the mutex.
-
Unit Tests:
ma_test.go: Added a new test functionTestResetto verify the behavior of theResetmethod, including checking the count, average, and values before and after resetting.