r/cpp • • 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

74 comments sorted by

View all comments

Show parent comment

1

u/snerp Aug 05 '26

Remove_if iterates the collection… E is not its own collection, it’s the elements in the collection original that will be removed. There is no look up cost, it just iterates to the next element and does a swap if your predicate was true.

https://en.cppreference.com/cpp/algorithm/remove

Complexity is O(N)

1

u/matthieum Aug 05 '26

I mean, if you can decide on the fly, sure, but that's not the usecase I was working on :x

1

u/snerp Aug 05 '26 edited Aug 05 '26

Decide what on the fly? Oh I see you're saying the elements E have no common trait so you'd have to do a collection on collection interaction 🤮