I am trying to wrap java.util.Array.binarySearch in a generic fashion in Scala, but the following code doesn't work:
def binarySlice[T](minValue: T, array: Array[T]): Array[T] = {
val i = java.util.Arrays.binarySearch(array, minValue)
val idx = if (i > 0) i else -i - 1
array.slice(idx, array.length)
}
The error is: Cannot resolve overloaded method 'binarySearch'. What should I do to make this code work?
Array[T]but they need another parameters.public static <T> int binarySearch(T[] a, T key, Comparator<? super T> c)andpublic static <T> int binarySearch(T[] a, int fromIndex, int toIndex, T key, Comparator<? super T> c)