10 dataHistory.set_capacity(windowSize);
11 medianBuffer.resize(windowSize);
17 dataHistory.push_back(
value);
18 std::copy(dataHistory.begin(), dataHistory.end(), medianBuffer.begin());
19 const auto n = dataHistory.size();
20 std::sort(medianBuffer.begin(), medianBuffer.begin() +
static_cast<long>(n));
21 float result = n % 2 == 0 ? (medianBuffer.at(n / 2 - 1) + medianBuffer.at(n / 2)) / 2
22 : medianBuffer.at(n / 2);
29 return medianBuffer.size();