krati.util
Class JenkinsHashFunction
java.lang.Object
krati.util.JenkinsHashFunction
- All Implemented Interfaces:
- HashFunction<byte[]>
public final class JenkinsHashFunction
- extends Object
- implements HashFunction<byte[]>
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.
Java port by Gray Watson http://256.com/gray/
Method Summary |
long |
hash(byte[] buffer)
See hash(byte[] buffer, long initialValue) |
long |
hash(byte[] buffer,
long initialValue)
Hash a variable-length key into a 32-bit value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JenkinsHashFunction
public JenkinsHashFunction()
hash
public long hash(byte[] buffer,
long initialValue)
- Hash a variable-length key into a 32-bit value. Every bit of the
key affects every bit of the return value. Every 1-bit and 2-bit
delta achieves avalanche. The best hash table sizes are powers of 2.
- Parameters:
buffer
- Byte array that we are hashing on.initialValue
- Initial value of the hash if we are continuing from
a previous run. 0 if none.
- Returns:
- Hash value for the buffer.
hash
public final long hash(byte[] buffer)
- See hash(byte[] buffer, long initialValue)
- Specified by:
hash
in interface HashFunction<byte[]>
- Parameters:
buffer
- Byte array that we are hashing on.
- Returns:
- Hash value for the buffer.
Copyright © 2011. All Rights Reserved.