Unify MutableList.reverse function template between JVM and JS
This commit is contained in:
@@ -780,6 +780,21 @@ public inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T>
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses elements in the list in-place.
|
||||
*/
|
||||
public fun <T> MutableList<T>.reverse(): Unit {
|
||||
val midPoint = (size / 2) - 1
|
||||
if (midPoint < 0) return
|
||||
var reverseIndex = lastIndex
|
||||
for (index in 0..midPoint) {
|
||||
val tmp = this[index]
|
||||
this[index] = this[reverseIndex]
|
||||
this[reverseIndex] = tmp
|
||||
reverseIndex--
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with elements in reversed order.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user