diff --git a/runtime/src/main/kotlin/kotlin/collections/Collections.kt b/runtime/src/main/kotlin/kotlin/collections/Collections.kt index 8a2c2200e05..249f6e8f2cb 100644 --- a/runtime/src/main/kotlin/kotlin/collections/Collections.kt +++ b/runtime/src/main/kotlin/kotlin/collections/Collections.kt @@ -958,10 +958,18 @@ public inline fun Iterable.takeWhile(predicate: (T) -> Boolean): List /** * Reverses elements in the list in-place. */ -@Fixme public fun MutableList.reverse(): Unit { - //java.util.Collections.reverse(this) - TODO() + val median = size / 2 + var leftIndex = 0 + var rightIndex = size - 1 + while (leftIndex < median) { + val tmp = this[leftIndex] + this[leftIndex] = this[rightIndex] + this[rightIndex] = tmp + leftIndex++ + rightIndex-- + } + } /**