| 2251 | |
| 2252 | template<typename T> |
| 2253 | static T CalculateTruncatedMedian(std::vector<T>& scores) |
| 2254 | { |
| 2255 | size_t size = scores.size(); |
| 2256 | if (size == 0) { |
| 2257 | return 0; |
| 2258 | } |
| 2259 | |
| 2260 | std::sort(scores.begin(), scores.end()); |
| 2261 | if (size % 2 == 0) { |
| 2262 | return (scores[size / 2 - 1] + scores[size / 2]) / 2; |
| 2263 | } else { |
| 2264 | return scores[size / 2]; |
| 2265 | } |
| 2266 | } |
| 2267 | |
| 2268 | void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_weight) |
| 2269 | { |
no test coverage detected