scala.util

object JenkinsHash

[source: scala/util/JenkinsHash.scala]

object JenkinsHash
extends AnyRef
Original algorithm due to Bob Jenkins. http://burtleburtle.net/bob/c/lookup3.c Scala version partially adapted from java version by Gray Watson. http://256.com/sources/jenkins_hash_java/JenkinsHash.java This is based on the 1996 version, not the 2006 version, and could most likely stand some improvement; the collision rate is negligible in my tests, but performance merits investigation.
Author
Paul Phillips
Value Summary
final val MAX_VALUE : Long = 4294967295L
Method Summary
def hash (buffer : Array[Byte], initialValue : Long) : Long
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.
def hashSeq (xs : Seq[Any]) : Int
Hash a sequence of anything into a 32-bit value. Descendants of AnyVal are broken down into individual bytes and mixed with some vigor, and this is summed with the hashCodes provided by the descendants of AnyRef.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
final val MAX_VALUE : Long

Method Details
def hashSeq(xs : Seq[Any]) : Int
Hash a sequence of anything into a 32-bit value. Descendants of AnyVal are broken down into individual bytes and mixed with some vigor, and this is summed with the hashCodes provided by the descendants of AnyRef.

def hash(buffer : Array[Byte], initialValue : Long) : Long
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.