问题
So ... I'm looking for a hash function that -- assuming no input skew -- will distribute nonempty Strings of (up to) 16 bytes "reasonably uniformly" onto a range [0..n]
where n
is user input but does not change over time.
And I should be able to argue why the function should provide that "resonably uniform" distribution.
In the end, all I need is a Java implementation of the hash function for use in a server and a reason "why" this hash function is suitable. So I'm looking less for "perfect uniform distribution" (if such a thing even exists) and more for "reasonably fast".
Still, I've never been much of a mathematician, so ...
- is there some native Java functionality that would provide such a hash?
- or any suggestion on how to come up with such a hash function?
来源:https://stackoverflow.com/questions/39791109/java-hash-function-to-distribute-strings-uniformly-in-a-given-range