Suppose that sizeof(void*) == sizeof(size_t)
and that hashing the pointer is just casting it to size_t
. So I want to know if my set contains an element, which will be faster std::set<void*>
or std::unordered_set<void*>
?
I know how std::set
works, but I am not familiar with std::unordered_set
. Well, I know that unordered set uses hashing and buckets and that if no intersection occurs (which is my case) the complexity is O(1). But I dont know how much is this constant complexity.
If how much date is in the container is relevant, my actual scenario uses less than a hundred¹. But my curiosity concerns both cases with few elements and a lot of elements.
¹ The amount of elements is so few that even a std::vector
would perform fine.