MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / EraseLastKElements

Function EraseLastKElements

src/net.cpp:985–990  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

983//! Sort an array by the specified comparator, then erase the last K elements.
984template<typename T, typename Comparator>
985static 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

Callers 1

Calls 4

beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected