Rename reverse to reversed.

#KT-8171
This commit is contained in:
Ilya Gorbunov
2015-08-10 15:54:09 +03:00
parent 56e12787a8
commit ca798d8d71
8 changed files with 170 additions and 69 deletions
@@ -89,13 +89,13 @@ fun elements(): List<GenericFunction> {
body(ArraysOfObjects) {
"""
if (element == null) {
for (index in indices.reverse()) {
for (index in indices.reversed()) {
if (this[index] == null) {
return index
}
}
} else {
for (index in indices.reverse()) {
for (index in indices.reversed()) {
if (element == this[index]) {
return index
}
@@ -106,7 +106,7 @@ fun elements(): List<GenericFunction> {
}
body(ArraysOfPrimitives) {
"""
for (index in indices.reverse()) {
for (index in indices.reversed()) {
if (element == this[index]) {
return index
}
@@ -6,11 +6,24 @@ fun ordering(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("reverse()") {
deprecate("reverse will change its behavior soon. Use reversed() instead.")
deprecateReplacement("reversed()")
doc { "Returns a list with elements in reversed order." }
returns { "List<T>" }
body { """return reversed()""" }
include(Strings)
returns(Strings) { "SELF" }
exclude(Sequences)
}
templates add f("reversed()") {
doc { "Returns a list with elements in reversed order." }
returns { "List<T>" }
body {
"""
if (this is Collection<*> && isEmpty()) return emptyList()
if (this is Collection && isEmpty()) return emptyList()
val list = toArrayList()
Collections.reverse(list)
return list
@@ -27,7 +40,7 @@ fun ordering(): List<GenericFunction> {
}
doc(Strings) { "Returns a string with characters in reversed order." }
returns(Strings) { "String" }
returns(Strings) { "SELF" }
body(Strings) {
// TODO: Replace with StringBuilder(this) when JS can handle it
"""