mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-09 15:43:48 +08:00
Update windowed_median.cpp
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* @author [Yaniv Hollander](https://github.com/YanivHollander)
|
||||
*/
|
||||
#include <cassert> // for assert
|
||||
#include <cstdint> // for std::uint32_t
|
||||
#include <cstdint> // for std::uint64_t
|
||||
#include <list> // for std::list - used to manage sliding window
|
||||
#include <set> // for std::multiset - used to manage multi-value sorted sliding window values
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace probability {
|
||||
* @brief A class to calculate the median of a leading sliding window at the back of a stream of integer values.
|
||||
*/
|
||||
class WindowedMedian {
|
||||
const std::uint32_t _windowSize; // Sliding window size
|
||||
const std::uint64_t _windowSize; // Sliding window size
|
||||
std::list<int> _window; // A sliding window of values along the stream
|
||||
std::multiset<int> _sortedValues; // A DS to represent a balanced multi-value binary search tree (BST)
|
||||
std::multiset<int>::const_iterator _itMedian; // An iterator that points to the root of the multi-value BST
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* @brief Constructs a WindowedMedian object
|
||||
* @param windowSize Sliding window size
|
||||
*/
|
||||
explicit WindowedMedian(std::uint32_t windowSize) : _windowSize(windowSize) {};
|
||||
explicit WindowedMedian(std::uint64_t windowSize) : _windowSize(windowSize) {};
|
||||
|
||||
/**
|
||||
* @brief Insert a new value to the stream
|
||||
|
||||
Reference in New Issue
Block a user