Simple non-recursive realisation of a splay tree.
"github.com/awskii/splay"
By default, Key has type int
, but you can change to fit your needs.
Key should be comparable.
$ go test -cover
PASS
coverage: 94.6% of statements
ok github.com/awskii/splay 0.180s
$ go test -bench=. -benchmem
goos: darwin
goarch: amd64
pkg: github.com/awskii/splay
(4 CPU) (Elements) (time/op) (memory overhead)
BenchmarkInsertIdle-4 20000000 67.8 ns/op 32 B/op 1 allocs/op
BenchmarkSearchIdle-4 50000000 21.2 ns/op 0 B/op 0 allocs/op
BenchmarkInsertRandom-4 1000000 1576 ns/op 32 B/op 1 allocs/op
BenchmarkSearchRandom-4 1000000 1525 ns/op 0 B/op 0 allocs/op