Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perfect Hash Function for URLs

Tags:

url

php

hash

Does anyone know of a perfect hashing function for URLs with 64-bit integers that would perform well for most URLs?

like image 819
Kristopher Ives Avatar asked Dec 14 '25 09:12

Kristopher Ives


1 Answers

It is impossible to create a perfect hash function if you don't know the set of keys that you will query in advance. If you know that, then you could use a something like gperf or cmph to generate the perfect hash function for you.

http://cmph.sourceforge.net/

I assume that a perfect hash function is not really what you want, so it suffices for you to use any reasonable hash function out there, like murmur hash or bob jenkins hash, with a hash table implementation, like __gnu_cxx::hash_map or dense_hash_map and sparse_hash_map from google.

http://code.google.com/p/google-sparsehash/ http://sites.google.com/site/murmurhash/ http://burtleburtle.net/bob/hash/doobs.html

like image 175
Davi Avatar answered Dec 17 '25 01:12

Davi



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!