Created
August 5, 2014 04:02
-
-
Save megawac/f4849d5ecc85539264ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sortedIndex(array, value, iterator, pivot) { | |
var low = 0, | |
high = array.length, | |
target = iterator(value); | |
while (low - pivot < high) { | |
var mid = (((low + high) >>> 1) + pivot) % array.length; | |
if (iterator(array[mid]) < target) low = mid + 1; | |
else high = mid; | |
} | |
return low; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment