golang-moving-average icon indicating copy to clipboard operation
golang-moving-average copied to clipboard

feat: add reset()

Open timebis opened this issue 1 year ago • 0 comments

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 Reset Method:

    • ma.go: Added a Reset method to the MovingAverage class to reset its internal state.
    • ma_concurrent.go: Added a Reset method to the ConcurrentMovingAverage class, ensuring thread safety by locking and unlocking the mutex.
  • Unit Tests:

    • ma_test.go: Added a new test function TestReset to verify the behavior of the Reset method, including checking the count, average, and values before and after resetting.

timebis avatar Dec 08 '24 19:12 timebis