Provide binarySearch with comparator for arrays.
This commit is contained in:
@@ -137,6 +137,13 @@ public fun ShortArray.asList(): List<Short> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted according to the specified [comparator].
|
||||
*/
|
||||
public fun <T> Array<out T>.binarySearch(element: T, comparator: Comparator<T>, fromIndex: Int = 0, toIndex: Int = size()): Int {
|
||||
return Arrays.binarySearch(this, fromIndex, toIndex, element, comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user