| 2973 | /// elements equals to val. "0" - val is located at index less |
| 2974 | /// then elements equals to val. |
| 2975 | @SuppressWarnings("unchecked") |
| 2976 | private static int find(Object[] arr, java.lang.Comparable val, int bnd, int l, int r) { |
| 2977 | int m = l; |
| 2978 | int d = 1; |
| 2979 | while (m <= r) { |
| 2980 | if (val.compareTo(arr[m]) > bnd) { |
| 2981 | l = m + 1; |
| 2982 | } else { |
| 2983 | r = m - 1; |
| 2984 | break; |
| 2985 | } |
| 2986 | m += d; |
| 2987 | d <<= 1; |
| 2988 | } |
| 2989 | while (l <= r) { |
| 2990 | m = (l + r) >>> 1; |
| 2991 | if (val.compareTo(arr[m]) > bnd) { |
| 2992 | l = m + 1; |
| 2993 | } else { |
| 2994 | r = m - 1; |
| 2995 | } |
| 2996 | } |
| 2997 | return l - 1; |
| 2998 | } |
| 2999 | |
| 3000 | /// Finds the place of specified range of specified sorted array, where the |
| 3001 | /// element should be inserted for getting sorted array. Uses exponential |