I have a list of memory addresses from 0xc0003000 to 0xc04a0144 there are many gaps and < 4096 entries in the list. It is known at compile time and I want to make a perfect hash for it.
However looking up perfect hashing online gives me information mostly related to hashing strings and they don't seem to translate well.
To be clear I want to be able to obtain the memory address at run time and check that it is in the hash quickly. Currently I am using a binary search which is on average about 8 loops to find the answer.
Any ideas what tree I should bark up?
gperf
sounds like exactly what you need. – Cutlassgperf -l
approach. I got it to work, but I'm not sure it'll be what you want. It does extra comparisons because it expects to work with strings of various lengths. There doesn't seem to be a way to tell it that the string will always be exactly 4 bytes. It might still be more efficient than some of the alternatives though. Should I post my code as an answer? – Perez