4 ms·
If we know that our HashSet is going to be containing u32s, couldn't we make a simple hash function that just takes the u32 and returns it? If our hashes are at
by librexpr 9y ago
If we know that our HashSet is going to be containing u32s, couldn't we make a simple hash function that just takes the u32 and returns it? If our hashes are at least 32 bit, this would both guarantee there are no hash collisions, and be super fast.
Heck, if we dived into the guts of the HashSet implementation, we could even remove any collision checks, because we'd know they can't happen.
- fred256 9y agoYou could go even a step further and ditch the hash table altogether, and just use a 2^32 bit set. “Only” takes up half a gigabyte of memory.