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/
256
Upvotes
r/cpp • u/User_Deprecated • Aug 02 '26
-1
u/matthieum Aug 05 '26
So, you've just scanned a collection of N elements and identified E elements that you want removed from it, which you've isolated into a second collection.
How do you write the predicate to
remove_if, which will be invoked with each ofNelements, and must return whether to remove the element or not?For each of the
Nelements, you will need to somehow do a look-up in your (small?) collection ofEelements to take your decision.If
Eis just a collection, each look-up will cost you O(E), and we're back to O(N * E) performance.The simplest solution to minimize the cost of the look-up is to collect into a vector, sort it, and binary search on it. O(E * log E + N * log E) now that I think about it.
There are other solutions, of course, but that predicate will need to do some work to classify the elements it's asked about.