Re: [go-nuts] Maps with non-comparable keys

2021-12-23 Thread aind...@gmail.com
> I think it is unlikely to ever happen Yeah, it'd require a language change wouldn't it? Still, it'd be nice to take advantage of the runtime's map implementation without starting from scratch. > I tried my hand at it for fun Nice work! I like the use of map[uint64][]keyVal. -- You received

Re: [go-nuts] Maps with non-comparable keys

2021-12-23 Thread Kevin Chowski
I tried my hand at it for fun :) it is a linear probed hashmap based on uint64 map keys: https://gotipplay.golang.org/p/gzrbS-B6ixg I claim no rights nor responsibility for the above example; it only took me like 20 minutes and has extremely minimal testing; it may contain bugs. Use at your own

Re: [go-nuts] Maps with non-comparable keys

2021-12-23 Thread Ian Lance Taylor
On Thu, Dec 23, 2021 at 12:42 PM aind...@gmail.com wrote: > > Now that generics is coming along, is there an easy way to extend the builtin > map type to use a non-comparable key type? For example, given this constraint > > type Key[T any] interface { > Size() uint64 > Hash(seed u

Re: [go-nuts] Maps with non-comparable keys

2021-12-23 Thread 'Axel Wagner' via golang-nuts
It is not possible and I think it is unlikely to ever happen (though it might be reasonably implemented as a library at some point). On Thu, Dec 23, 2021 at 9:42 PM aind...@gmail.com wrote: > Now that generics is coming along, is there an easy way to extend the > builtin map type to use a non-co

[go-nuts] Maps with non-comparable keys

2021-12-23 Thread aind...@gmail.com
Now that generics is coming along, is there an easy way to extend the builtin map type to use a non-comparable key type? For example, given this constraint type Key[T any] interface { Size() uint64 Hash(seed uint64) uint64 Equal(T) bool } and a type Foo like type Foo []