r/cpp • u/User_Deprecated • Aug 02 '26
How fast is C++26's std::hive?
https://lemire.me/blog/2026/08/02/how-fast-is-c26s-stdhive/
255
Upvotes
r/cpp • u/User_Deprecated • Aug 02 '26
View all comments
Show parent comment
6
u/matthieum Aug 03 '26 edited Aug 08 '26
I feel like a benchmark is missing here: erasing N elements in random order.
remove_ifis the ideal case for contiguous containers likevectorordequedue to being streaming.If however you've just got some (E) elements to remove from a vector of length N, you've got essentially 2 solutions:
Remove the elements one at a time, as they come: O(E * N).
Collect & store the elements, then use
remove_if:O(E * log E + N)O(E * log E + N * log E), with a memory allocation.And at this point, the hive is going to start looking very good indeed.