Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

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

Comments

Projects
None yet
2 participants
Contributor

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;
  };
Owner

jashkenas commented Sep 20, 2012

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