Does anyone know of a perfect hashing function for URLs with 64-bit integers that would perform well for most URLs?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Found this marked as a
"Base52 url shortener perfect hash function in C"
from http://lambdajones.com/b52It 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