What does that sort.Find do that is new ? Does it just give index number between 0 and N and generate those index by binary searching ? That’s IMO really weird interface ? Why not take a slice and a comparison closure taking one or two Ts and keeping the way the indexing works private ?
Sure, those are the APIs I would expect. So I don’t understand what the sort.Find does that is “new” ? (except presenting a definitely weird interface to its user)
It’s the “new” part of the statement I don’t understand. (and to a lesser degree, the interface design)
It’s not “new” in that sense. Rob Pike just felt like sort.Search was too awkward, so he proposed a new function that’s maybe 10% less awkward. It’s the same functionality either way.
I yearn for the day when Go removes all mentions of sort.Interface lol. Thanks for work BTW.
I actually always really appreciated the cleverness of sort.Interface. It really showed what the language designers were going for.
What were they going for?
They were, as far as I can tell, trying to show the power of nominative types combined with interfaces.
They finally fixed the ballast thing!
I plan to continue to allocate an extra 100MB slab, for luck.
What does that
sort.Find
do that is new ? Does it just give index number between 0 and N and generate those index by binary searching ? That’s IMO really weird interface ? Why not take a slice and a comparison closure taking one or twoT
s and keeping the way the indexing works private ?There’s also https://pkg.go.dev/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/slices#BinarySearch. Does that do what you want?
Sure, those are the APIs I would expect. So I don’t understand what the
sort.Find
does that is “new” ? (except presenting a definitely weird interface to its user)It’s the “new” part of the statement I don’t understand. (and to a lesser degree, the interface design)
It’s not “new” in that sense. Rob Pike just felt like sort.Search was too awkward, so he proposed a new function that’s maybe 10% less awkward. It’s the same functionality either way.
You can use it for things other than slices. For example, you could use it to implement something like git-bisect