Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping function

I have a set of 128bit number and the size of set < 2^32 ...so theoretically I can have a mapping function that maps all the 128bit numbers to 32 bit number ....how can I construct the mapping function ???

like image 266
Avishek Bhattacharya Avatar asked Jun 04 '26 06:06

Avishek Bhattacharya


1 Answers

Seems like you are looking for a minimal perfect hash which maps n keys to n consecutive integers.

The wiki page link in the above sentence mentions two libraries which implement this.

Also see this for more detail: http://burtleburtle.net/bob/hash/perfect.html


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!