I work with unordered_set.
Here it’s written that it has a reserve function which
set buckets based on number of elements N to contain.
However, mpic++ compiler on Ubuntu complains that there is no function reserve:
class std::tr1::unordered_set<pair_int>’ has no member named ‘reserve’
I need to optimize my set to hold N elements,
it seems the max_load_factor is available, how do I come with one based on N?
Or can I optimize it somehow else?
Thanks in advance
p/s/ saw some discussion for java, but not for c++ stl lib
Load factor is independent of the number of items you insert. It’s basically the percentage of available space that’s actually in use. If, for example, you currently have space for 100 elements allocated, the maximum load factor could say to start resizing the table when you had inserted, say, 80 items (this would correspond to a maximum load factor of 80%).
Setting the maximum load factor is, therefore, largely independent of the number of elements you’re going to store. Rather, it’s (mostly) an indication of how much extra space you’re willing to use to improve search speed. All else being equal, a table that’s closer to full will have more collisions, which will slow searching.