func name change
parent
a4e3ee6a57
commit
20cd3d83f1
|
@ -0,0 +1,4 @@
|
|||
- Panic in verification that 2*eps is less than bucket width.
|
||||
Make sure the "if" equality is correct.
|
||||
|
||||
- Make sure hash contains ":" between bucket numbers. Or the analogy to ":".
|
|
@ -6,10 +6,12 @@ import (
|
|||
"hash/fnv"
|
||||
)
|
||||
|
||||
// Hash64 can be any function of this kind.
|
||||
type Hash64 func(buckets []int) uint64
|
||||
|
||||
// Fnva64 returns a FVN-1a hash for a slice of bucket numbers.
|
||||
func Fnva64(buckets []int) uint64 {
|
||||
// Default is the default Hash64 function for this package.
|
||||
// It returns a FVN-1a hash for a slice of bucket numbers.
|
||||
func Default(buckets []int) uint64 {
|
||||
var b bytes.Buffer
|
||||
gob.NewEncoder(&b).Encode(buckets)
|
||||
hash := fnv.New64a()
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestFnva64(t *testing.T) {
|
||||
func TestDefault(t *testing.T) {
|
||||
buckets := []int{5, 59, 255, 9, 7, 12, 22, 31}
|
||||
hash := Fnva64(buckets)
|
||||
hash := Default(buckets)
|
||||
want := uint64(13992349377752315208)
|
||||
if hash != want {
|
||||
t.Errorf(`Got %v, want %v`, hash, want)
|
||||
|
@ -20,7 +20,7 @@ func TestHashes64(t *testing.T) {
|
|||
{1, 0, 7, 3, 0, 0, 9},
|
||||
{0, 0, 8, 3, 0, 0, 9},
|
||||
{1, 0, 8, 3, 0, 0, 9}}
|
||||
hs := Hashes64(tree, Fnva64)
|
||||
hs := Hashes64(tree, Default)
|
||||
want := []uint64{
|
||||
14647827280143437043,
|
||||
17530493565529410009,
|
||||
|
|
Loading…
Reference in New Issue