Source File
murmur.go
Belonging Package
github.com/spaolacci/murmur3
// 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/MurmurHash3History, characteristics and (legacy) perfs:https://sites.google.com/site/murmurhash/https://sites.google.com/site/murmurhash/statistics*/package murmur3type 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()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |