Closed zsnjuts closed 1 year ago
You should not use a minimal perfect hash function inside a std::unordered_map
.
Your pt_map vector is where your data should be stored, as indexed by pthash.
Please, read the issue you referenced: it is also explained there how to proceed.
You see, in fact, that pthash is 2X than a std::unordered_map
with (essentially) optimal space usage: you only pay the cost for your data. You also have no collisions. The only downside is that a minimal perfect hash function is static by design.
Hope my explanation helps.
Can I close this issue or do you need further help/explanation?
I'm closing this but feel free to text me if needed.
I think one of the issues is that pthash, like several other PMHF's, is not order-preserving.
Most PMHF's map to the range {0, 1, ..., m - 1}
, but without the order-preserving property you cant really create e.g. a flat array map implementation without using an offset array, which needs at least O(mlog2(m))
bits to store
This issue says that pthash has not map implementation, but It seems that we can use pthash as the hash function of std::unordered_map.
To my surprise,
pt_umap
even performs worse than the default hash function. Is there a problem with the use of the above code? Here is my benchmark code:The results are: