Notes:
- The Entry interface now has a type parameter, so that it can talk
about its own underlying type.
- Methods which relied on being able to return nil for the entry now
return a pointer to the type.
- We now use the any alias instead of interface{} anywhere it was left
after adding type parameters.
- In tests, instances of `assert.Equal(t, nil, ...)` have been changed
to `assert.Nil(t, ...)`. This is because assert.Equal does not
consider the untyped nil constant to be equal to a nil pointer of a
particular type; probably it worked before because the other argument
was an interface.
Benchmarks are broadly similar. Before:
goos: linux
goarch: amd64
pkg: github.com/raviqqe/hamt
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
BenchmarkHamtInsert-8 195 6086113 ns/op
BenchmarkHamtDelete-8 710 1626577 ns/op
BenchmarkHamtFirstRestIteration-8 1 4049853564 ns/op
BenchmarkHamtForEachIteration-8 9024 112623 ns/op
BenchmarkBuiltinMapForEach-8 13258 87643 ns/op
BenchmarkBuiltinSliceForEach-8 496905 2403 ns/op
BenchmarkSetInsert-8 121 10263234 ns/op
BenchmarkSetSize-8 32 35424252 ns/op
--- BENCH: BenchmarkSetSize-8
set_test.go:160: 1
set_test.go:160: 2
set_test.go:160: 3
set_test.go:160: 4
set_test.go:160: 5
set_test.go:160: 6
set_test.go:160: 7
set_test.go:160: 8
set_test.go:160: 9
set_test.go:160: 10
... [output truncated]
PASS
ok github.com/raviqqe/hamt 27.370s
...And after:
goos: linux
goarch: amd64
pkg: github.com/raviqqe/hamt
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
BenchmarkHamtInsert-8 193 6351027 ns/op
BenchmarkHamtDelete-8 733 1539728 ns/op
BenchmarkHamtFirstRestIteration-8 1 4908351503 ns/op
BenchmarkHamtForEachIteration-8 15807 71250 ns/op
BenchmarkBuiltinMapForEach-8 13308 89030 ns/op
BenchmarkBuiltinSliceForEach-8 485073 2444 ns/op
BenchmarkSetInsert-8 138 9306362 ns/op
BenchmarkSetSize-8 37 30683603 ns/op
--- BENCH: BenchmarkSetSize-8
set_test.go:160: 1
set_test.go:160: 2
set_test.go:160: 3
set_test.go:160: 4
set_test.go:160: 5
set_test.go:160: 6
set_test.go:160: 7
set_test.go:160: 8
set_test.go:160: 9
set_test.go:160: 10
... [output truncated]
PASS
ok github.com/raviqqe/hamt 30.325s
Co-authored-by: Yota Toyama <[email protected]>