Skip to content

_.sortedIndex should use `>>>` instead of `>>` to support the full length range of arrays. #735

Closed
jdalton opened this Issue Sep 2, 2012 · 1 comment

2 participants

@jdalton
jdalton commented Sep 2, 2012

_.sortedIndex should use >>> instead of >> to support the full length range of arrays.

  _.sortedIndex = function(array, obj, iterator) {
    iterator || (iterator = _.identity);
    var value = iterator(obj);
    var low = 0, high = array.length;
    while (low < high) {
      var mid = (low + high) >>> 1;
      iterator(array[mid]) < value ? low = mid + 1 : high = mid;
    }
    return low;
  };
@jashkenas
Owner

I'd like to see you find the sorted index on an array that large ... but sure ;)

@jashkenas jashkenas closed this Sep 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.