ghedeon
10/11/2018, 2:21 PMIntArray.binarySearch but that's only for ascending. Arrays.binarySearch allows you to specify the comparator but only for the Array<T>, not for the IntArray. Seems like a dead end.Egor Trutenko
10/11/2018, 2:35 PMIntArray.binarySearch internally calls Arrays.binarySearch defined for int[] anyways. Either you sort your array explicitly, or you box your values and call Arrays.binarySearch for Array<T> with comparatorghedeon
10/11/2018, 2:44 PMIntArray. Can't think of blockers here.ghedeon
10/11/2018, 2:48 PMArray<T> copy? That also looks redundant. Idk, it's a first time when I see that Array<Int> could be a better choice and I'm confused why.Ruckus
10/11/2018, 2:48 PMRuckus
10/11/2018, 2:49 PMhudsonb
10/11/2018, 2:50 PMhudsonb
10/11/2018, 2:51 PMarr.toList().asReversed().binarySearch(...) avoids the N reversing costghedeon
10/11/2018, 2:53 PMghedeon
10/11/2018, 2:54 PMasReversed(), the nr.2 still apply, thohudsonb
10/11/2018, 2:55 PMghedeon
10/11/2018, 2:56 PMghedeon
10/11/2018, 2:57 PMArrays for other caseshudsonb
10/11/2018, 3:07 PMarr.asList().binarySearch(n, Comparator { o1, o2 -> o2 - o1 })hudsonb
10/11/2018, 3:11 PMghedeon
10/11/2018, 3:11 PMtoTypedArray(). Thank you!hudsonb
10/11/2018, 3:13 PMfun IntArray.binarySearch(element: Int, comparator: Comparator<Int>)
= asList().binarySearch(8, comparator)hudsonb
10/11/2018, 3:14 PMelement not 8hudsonb
10/11/2018, 3:15 PMghedeon
10/11/2018, 3:25 PMComparisons.reverseOrder() to make it cleaner. 😉hudsonb
10/11/2018, 3:50 PMDico
10/11/2018, 4:07 PMIntComparator which is Java's comparator for primitive ints.Dico
10/11/2018, 4:08 PM