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