You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
I find it unintuitive that
bisectCenter
can return a value that is less than bothbisectLeft
andbisectRight
. Based on howbisectLeft
andbisectRight
work, I would expectbisectCenter
to either matchbisectLeft
andbisectRight
(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 renamebisector
tolocator
or something more general and then havebisectLeft
,bisectRight
, andclosestIndex
instead of.left
,.right
, and.center
.Bisect Examples
The text was updated successfully, but these errors were encountered: