https://kotlinlang.org logo
#getting-started
Title
# getting-started
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
Copy code
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.
4 Views