in reply to Generating Unique numbers from Unique strings
In other words: you're looking for a way to enumerate a bag of strings.
As far as algorithms go, (Minimal) Perfect Hashing can do it. However. Those mappings typically involve lookups in two or three tables i.e. random memory accesses, whereas straightforward hashing needs just one. So going via enumeration will probably cost you 4x compared to simple hash lookup.
When it comes to hashing, there are various complicated monstrosities out there — such as dense maps — that serve a particular purpose (trading speed for compactness). Speed-wise, you can't beat the traditional hash.
|
|---|