I need to create medium sized static hash tables from it. As a rule, they will have 5-100 entries. When the hash table is created, all key hashes are known in advance (that is, the keys have already been hashed.) I am currently creating a HashMap that sorts the keys, so I get an O (log n) search, which 3-5 searches on average in size that excite me. Wikipediaclaims that a simple hash table with a chain will lead to an average search result of 3 tables for the full table, so this is not a problem for me (i.e. take the% n hash as the first record and make the chain). Given that I know all the hashes at the beginning, it seems like there should be an easy way to get a fast, static perfect hash - but I just couldn't find a good pointer. That is, O (1) access is amortized without additional (insignificant?) Additional overhead. How to implement such a static table?
Memory usage is important, so the less I need to store, the better.
Edit: Please note that this is normal if I need to resolve one collision or so manually. That is, if I could make some chain, which, on average, had direct access and, for example, 3 items, for example, a fine. It is not that I need a perfect hash.
source
share