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

x/exp/slices: BinarySearchFunc slice sort undefined #59685

Closed
crisman opened this issue Apr 17, 2023 · 1 comment
Closed

x/exp/slices: BinarySearchFunc slice sort undefined #59685

crisman opened this issue Apr 17, 2023 · 1 comment

Comments

@crisman
Copy link
Contributor

crisman commented Apr 17, 2023

While thinking about #59260 and #57348 (and #57433) there is now a problem with
BinarySearchFunc() (at least the documentation):

BinarySearchFunc works like BinarySearch, but uses a custom comparison
function. The slice must be sorted in increasing order, where "increasing" is
defined by cmp. cmp(a, b) is expected to return an integer comparing the two
parameters: 0 if a == b, a negative number if a < b and a positive number if
a > b.

"defined by cmp" is problematic after #57348, as to sort the slice both parameters
need to be of the same type as the slice elements. If code is using a cmp where E is
not T then the sort of x is not defined.

@gopherbot gopherbot added this to the Unreleased milestone Apr 17, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/485995 mentions this issue: slices: update BinarySearchFunc docs for CL 464456

@golang golang locked and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants