Hi Guys, is it possible to implement generic, efficient binary search using generics or interfaces. So i'll have some index, and data inside single struct and then could just define a comparison function between 2 variables of same type index which will return bool.
Will have 20-30 million datapoints type abc struct { index uint32 data1 []byte data2 []string } type bcd struct { index [4]byte data1 []byte data2 []string } a = []abc{...} b = []bcd{...} find(a, 217621) find(b, [4]byte{1,2,54,11}) Currently i have this, which is probably incorrect: type comparable[TC any] interface { compare(TC, TC) bool } func bin[T comparable](data []T, find T) int { } Is that even possible to do efficiently or i should just go with writing separated code for each struct type ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a7e769c3-70a7-4aa6-96a5-453a55db3e60n%40googlegroups.com.