// Copyright 2013, Sébastien Paolacci. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/* Package murmur3 implements Austin Appleby's non-cryptographic MurmurHash3. Reference implementation: http://code.google.com/p/smhasher/wiki/MurmurHash3 History, characteristics and (legacy) perfs: https://sites.google.com/site/murmurhash/ https://sites.google.com/site/murmurhash/statistics */
package murmur3 type bmixer interface { bmix(p []byte) (tail []byte) Size() (n int) reset() } type digest struct { clen int // Digested input cumulative length. tail []byte // 0 to Size()-1 bytes view of `buf'. buf [16]byte // Expected (but not required) to be Size() large. seed uint32 // Seed for initializing the hash. bmixer } func ( *digest) () int { return 1 } func ( *digest) ( []byte) ( int, error) { = len() .clen += if len(.tail) > 0 { // Stick back pending bytes. := .Size() - len(.tail) // nfree ∈ [1, d.Size()-1]. if < len() { // One full block can be formed. := append(.tail, [:]...) = [:] _ = .bmix() // No tail. } else { // Tail's buf is large enough to prevent reallocs. = append(.tail, ...) } } .tail = .bmix() // Keep own copy of the 0 to Size()-1 pending bytes. := copy(.buf[:], .tail) .tail = .buf[:] return , nil } func ( *digest) () { .clen = 0 .tail = nil .bmixer.reset() }