Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generics #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Support generics #16

wants to merge 1 commit into from

Conversation

kasegao
Copy link

@kasegao kasegao commented Oct 27, 2022

Added generics for all levels of OrderedMap implementation.
For backward compatibility, generics is only enabled on go 1.18 and later versions.

Most structures and functions can be called with the original name with a suffix "G". For example, "OrderMapG" is a generics version of "OrderMap".

Here are the results of my benchmark tests:

> go test -bench . -benchmem
goos: windows
goarch: amd64
pkg: github.com/cevaris/ordered_map
cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
BenchmarkSet_OrderedMap-12               1350037               759.2 ns/op           261 B/op          3 allocs/op
BenchmarkSet_OrderedMapG-12              5101459               248.8 ns/op            99 B/op          1 allocs/op
BenchmarkGet_OrderedMap-12              15139624                93.70 ns/op            0 B/op          0 allocs/op
BenchmarkGet_OrderedMapG-12             21065011                76.77 ns/op            0 B/op          0 allocs/op
BenchmarkDelete_OrderedMap-12            3796270               332.9 ns/op             0 B/op          0 allocs/op
BenchmarkDelete_OrderedMapG-12          10951123               128.5 ns/op             0 B/op          0 allocs/op
PASS
ok      github.com/cevaris/ordered_map  45.006s

@cevaris
Copy link
Owner

cevaris commented Nov 1, 2022

go test -bench . -benchmem
can we also add a new Makefile target, and update the README.md to say how to run benchmarks; ie. go bench.

bench:
	go test -bench . -benchmem

@cevaris
Copy link
Owner

cevaris commented Nov 1, 2022

To confirm, the original non-generic code cannot be reused for generic code? If so, that would be ideal?

@eugbyte
Copy link

eugbyte commented Apr 3, 2023

Please approve and merge this PR, it would be very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants