https://kotlinlang.org logo
Title
t

Trevor Hackman

03/08/2022, 10:06 PM
Hi, I was interested in suggesting a new standard library function in kotlin.collections and in writing it myself and making a pull request to contribute, Is this something that would be of interest? I found myself wanting this function but it not existing in the standard library, it would be
binarySearchIndexed
With a signature of perhaps
fun <T : Comparable<T>> List<T>.binarySearchIndexed(
    fromIndex: Int = 0,
    toIndex: Int = size,
    comparison: (T, Int) -> Int,
): Int
d

Dominaezzz

03/08/2022, 10:12 PM
Not quite the same but you can
.withIndex().binarySearch { ... }
.
Ask in #stdlib.