1014f07c7SMatthew Barth #pragma once
2014f07c7SMatthew Barth 
3014f07c7SMatthew Barth #include "types.hpp"
4014f07c7SMatthew Barth 
5*3e1bb274SMatthew Barth #include <vector>
6*3e1bb274SMatthew Barth 
7014f07c7SMatthew Barth namespace phosphor
8014f07c7SMatthew Barth {
9014f07c7SMatthew Barth namespace fan
10014f07c7SMatthew Barth {
11014f07c7SMatthew Barth namespace control
12014f07c7SMatthew Barth {
13014f07c7SMatthew Barth namespace utility
14014f07c7SMatthew Barth {
15014f07c7SMatthew Barth 
16014f07c7SMatthew Barth /**
17014f07c7SMatthew Barth  * @brief A utility function to return a median value
18014f07c7SMatthew Barth  * @details A median value is determined from a set of values where the middle
19014f07c7SMatthew Barth  * value is returned from an odd set of values and an average of the middle
20014f07c7SMatthew Barth  * two values for an even set of values.
21014f07c7SMatthew Barth  *
22014f07c7SMatthew Barth  * @param[in] values - Set of values to determine the median from
23014f07c7SMatthew Barth  *
24014f07c7SMatthew Barth  * @return A median value
25014f07c7SMatthew Barth  *
26014f07c7SMatthew Barth  * @throw std::out_of_range Empty list of values given
27014f07c7SMatthew Barth  *
28014f07c7SMatthew Barth  * Note: The set of values will be partially re-ordered
29014f07c7SMatthew Barth  * https://en.cppreference.com/w/cpp/algorithm/nth_element
30014f07c7SMatthew Barth  */
31014f07c7SMatthew Barth int64_t getMedian(std::vector<int64_t>& values);
32014f07c7SMatthew Barth 
33014f07c7SMatthew Barth } // namespace utility
34014f07c7SMatthew Barth } // namespace control
35014f07c7SMatthew Barth } // namespace fan
36014f07c7SMatthew Barth } // namespace phosphor
37