| 983 | //! Sort an array by the specified comparator, then erase the last K elements. |
| 984 | template<typename T, typename Comparator> |
| 985 | static void EraseLastKElements(std::vector<T> &elements, Comparator comparator, size_t k) |
| 986 | { |
| 987 | std::sort(elements.begin(), elements.end(), comparator); |
| 988 | size_t eraseSize = std::min(k, elements.size()); |
| 989 | elements.erase(elements.end() - eraseSize, elements.end()); |
| 990 | } |
| 991 | |
| 992 | /** Try to find a connection to evict when the node is full. |
| 993 | * Extreme care must be taken to avoid opening the node to attacker |
no test coverage detected