blob: 3458180896524adf41680b584756e342d9864f2a [file] [log] [blame]
Matthew Barth014f07c2019-05-30 09:55:42 -05001#pragma once
2
3#include <vector>
4#include "types.hpp"
5
6namespace phosphor
7{
8namespace fan
9{
10namespace control
11{
12namespace 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 */
30int64_t getMedian(std::vector<int64_t>& values);
31
32} // namespace utility
33} // namespace control
34} // namespace fan
35} // namespace phosphor