Package com.linkedin.alpini.base.hash
Class JenkinsHashFunction
java.lang.Object
com.linkedin.alpini.base.hash.JenkinsHashFunction
- All Implemented Interfaces:
HashFunction
Hash algorithm by Bob Jenkins, 1996.
You may use this code any way you wish, private, educational, or commercial. It's free.
See: http://burtleburtle.net/bob/hash/doobs.html
Use for hash table lookup, or anything where one collision in 2^^32
is acceptable. Do NOT use for cryptographic purposes.
Reimplementation from http://burtleburtle.net/bob/c/lookup3.c to match test vectors
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
hash
(byte[] key, int numBuckets) long
hash
(long key, int numBuckets) long
hash
(ByteBuffer buf) long
hash
(ByteBuffer buf, int off, int len) int
hashlittle
(ByteBuffer k, int initval) long
hashlittle2
(ByteBuffer k, long initval) int
long
-
Constructor Details
-
JenkinsHashFunction
public JenkinsHashFunction()
-
-
Method Details
-
hashword
-
hashword2
-
hashlittle
-
hashlittle2
-
hash
- Specified by:
hash
in interfaceHashFunction
-
hash
- Specified by:
hash
in interfaceHashFunction
-
hash
public long hash(byte[] key, int numBuckets) - Specified by:
hash
in interfaceHashFunction
-
hash
public long hash(long key, int numBuckets) - Specified by:
hash
in interfaceHashFunction
-