d3-array icon indicating copy to clipboard operation
d3-array copied to clipboard

bisectCenter naming

Open dakoop opened this issue 4 years ago • 0 comments

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

dakoop avatar Nov 03 '21 16:11 dakoop