| 950 | //! Sort an array by the specified comparator, then erase the last K elements where predicate is true. |
| 951 | template <typename T, typename Comparator> |
| 952 | static void EraseLastKElements( |
| 953 | std::vector<T>& elements, Comparator comparator, size_t k, |
| 954 | std::function<bool(const NodeEvictionCandidate&)> predicate = [](const NodeEvictionCandidate& n) { return true; }) |
| 955 | { |
| 956 | std::sort(elements.begin(), elements.end(), comparator); |
| 957 | size_t eraseSize = std::min(k, elements.size()); |
| 958 | elements.erase(std::remove_if(elements.end() - eraseSize, elements.end(), predicate), elements.end()); |
| 959 | } |
| 960 | |
| 961 | void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& eviction_candidates) |
| 962 | { |
no test coverage detected