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

bisectCenter naming #239

Closed
dakoop opened this issue Nov 3, 2021 · 1 comment
Closed

bisectCenter naming #239

dakoop opened this issue Nov 3, 2021 · 1 comment

Comments

@dakoop
Copy link

dakoop commented Nov 3, 2021

I find it unintuitive that bisectCenter can return a value that is less than both bisectLeft and bisectRight. Based on how bisectLeft and bisectRight work, I would expect bisectCenter to either match bisectLeft and bisectRight (if the value doesn't exist in the array) or give me the index in the middle of a sequence of equal values. Reading the documentation and #138, I now understand that this method is accomplishing something different.

To me, it would make sense to rename this method to something like closestIndex (even though the implementation uses a bisector). One could also rename bisector to locator or something more general and then have bisectLeft, bisectRight, and closestIndex instead of .left, .right, and .center.

Bisect Examples

@mbostock
Copy link
Member

Thanks for the feedback. I understand that the name could be confusing, but I’d rather just leave it as is now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants