blob: ba626b342fc72852b8674dc8b182bb0350754917 [file] [log] [blame]
Matthew Barth014f07c2019-05-30 09:55:42 -05001#pragma once
2
Matthew Barth014f07c2019-05-30 09:55:42 -05003#include "types.hpp"
4
Matthew Barth3e1bb272020-05-26 11:09:21 -05005#include <vector>
6
Matthew Barth014f07c2019-05-30 09:55:42 -05007namespace phosphor
8{
9namespace fan
10{
11namespace control
12{
13namespace utility
14{
15
16/**
17 * @brief A utility function to return a median value
18 * @details A median value is determined from a set of values where the middle
19 * value is returned from an odd set of values and an average of the middle
20 * two values for an even set of values.
21 *
22 * @param[in] values - Set of values to determine the median from
23 *
24 * @return A median value
25 *
26 * @throw std::out_of_range Empty list of values given
27 *
28 * Note: The set of values will be partially re-ordered
29 * https://en.cppreference.com/w/cpp/algorithm/nth_element
30 */
31int64_t getMedian(std::vector<int64_t>& values);
32
33} // namespace utility
34} // namespace control
35} // namespace fan
36} // namespace phosphor