Closed shmul closed 1 year ago
That function was removed in favor of more flexible hash/maphash
-based hash functions. See an example of such function here: https://github.com/puzpuzpuz/xsync/blob/ace0f0f74f9efcf6f83a907113446b7497eab72d/example_test.go#L21-L32
If you have string
keys, it's trivial to implement a hash function with maphash.Hash
:
func(seed maphash.Seed, s string) uint64 {
var h maphash.Hash
h.SetSeed(seed)
h.WriteString(s)
return h.Sum64()
}
Thanks for the reply. It is well understood and seems right. All I'm asking for is to make it a public utility function as string keys are so common.
There are NewMapOf
and NewMapOfPresized
built-in constructors for typed maps with string
keys, so a separate function is not needed. Sorry for not mentioning this initially.
Perfect. Many thanks.
No problem at all. Feel free to reopen this issue or create a separate one if you find that the library API could be improved.
Hi,
The
xsync.StrHash64
function ofv1
was very helpful and it is a shamed it is missing fromv2
. Any reason why you decided not to makehashString
public? I'll be happy to issue a pull request with such a change.Cheers, Shmul