diff --git a/NEXT b/NEXT new file mode 100644 index 0000000..0d5e890 --- /dev/null +++ b/NEXT @@ -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 ":". \ No newline at end of file diff --git a/hashes.go b/hashes.go index 1ba82d7..a313277 100644 --- a/hashes.go +++ b/hashes.go @@ -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() diff --git a/hashes_test.go b/hashes_test.go index 946744d..ce89755 100644 --- a/hashes_test.go +++ b/hashes_test.go @@ -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,