function getIndex(arr,val){ var min = 0,max=arr.length-1,mid; while(min<=max){ mid = (max+min)/2; if(val>arr[mid]){ min = mid+1; }else if(val<arr[mid]){ max = mid-1; }else{ return mid; } } return min; }
function getIndex(arr,val){ var min = 0,max=arr.length-1,mid; while(min<=max){ mid = (max+min)/2; if(val>arr[mid]){ min = mid+1; }else if(val<arr[mid]){ max = mid-1; }else{ return mid; } } return min; }