1 #pragma once
2 
3 #include "types.hpp"
4 
5 #include <vector>
6 
7 namespace phosphor
8 {
9 namespace fan
10 {
11 namespace control
12 {
13 namespace 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  */
31 int64_t getMedian(std::vector<int64_t>& values);
32 
33 } // namespace utility
34 } // namespace control
35 } // namespace fan
36 } // namespace phosphor
37