Compute the hash of an array.
Compute the hash of an array.
Compute the hash of a byte array.
Compute the hash of a byte array. Faster than arrayHash, because it hashes 4 bytes at once.
Finalize a hash to incorporate the length and make sure all bits avalanche.
Finalize a hash to incorporate the length and make sure all bits avalanche.
Mix in a block of data into an intermediate hash value.
Mix in a block of data into an intermediate hash value.
May optionally be used as the last mixing step.
May optionally be used as the last mixing step. Is a little bit faster than mix, as it does no further mixing of the resulting hash. For the last element this is not necessary as the hash is thoroughly mixed during finalization anyway.
Compute a hash that depends on the order of its arguments.
Compute a hash that depends on the order of its arguments.
Compute the hash of a product
Compute the hash of a product
To offer some potential for optimization.
Compute the hash of a string
Compute the hash of a string
Compute a hash that is symmetric in its arguments - that is a hash where the order of appearance of elements does not matter.
Compute a hash that is symmetric in its arguments - that is a hash where the order of appearance of elements does not matter. This is useful for hashing sets, for example.
def linearSeqHash(xs: scala.
def linearSeqHash(xs: scala.collection.LinearSeq[_], seed: Int): Int = { var n = 0 var h = seed var elems = xs while (elems.nonEmpty) { h = mix(h, elems.head.##) n += 1 elems = elems.tail } finalizeHash(h, n) }
def indexedSeqHash(xs: scala.collection.IndexedSeq[_], seed: Int): Int = { var n = 0 var h = seed val len = xs.length while (n < len) { h = mix(h, xs(n).##) n += 1 } finalizeHash(h, n) }
(Since version 2.10.0) Use unorderedHash
(Since version 2.10.0) Use orderedHash
An implementation of Austin Appleby's MurmurHash 3 algorithm (MurmurHash3_x86_32). This object contains methods that hash values of various types as well as means to construct
Hashing
objects.This algorithm is designed to generate well-distributed non-cryptographic hashes. It is designed to hash data in 32 bit chunks (ints).
The mix method needs to be called at each step to update the intermediate hash value. For the last chunk to incorporate into the hash mixLast may be used instead, which is slightly faster. Finally finalizeHash needs to be called to compute the final hash value.
This is based on the earlier MurmurHash3 code by Rex Kerr, but the MurmurHash3 algorithm was since changed by its creator Austin Appleby to remedy some weaknesses and improve performance. This represents the latest and supposedly final version of the algortihm (revision 136).
http://code.google.com/p/smhasher