Drop deprecated sorting and reversing methods.

This commit is contained in:
Ilya Gorbunov
2015-09-29 22:31:01 +03:00
parent e54db8cd2a
commit 0b88801c66
5 changed files with 129 additions and 581 deletions
-293
View File
@@ -4084,78 +4084,6 @@ public inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List<Shor
return list
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun <T> Array<out T>.reverse(): List<T> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun BooleanArray.reverse(): List<Boolean> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun ByteArray.reverse(): List<Byte> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun CharArray.reverse(): List<Char> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun DoubleArray.reverse(): List<Double> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun FloatArray.reverse(): List<Float> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun IntArray.reverse(): List<Int> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun LongArray.reverse(): List<Long> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun ShortArray.reverse(): List<Short> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@@ -4354,38 +4282,6 @@ public fun ShortArray.reversedArray(): ShortArray {
return result
}
/**
* Returns a list of all elements, sorted by the specified [comparator].
*/
@Deprecated("This method may change its behavior soon. Use sortedWith() instead.", ReplaceWith("sortedWith(comparator)"))
public fun <T> Array<out T>.sortBy(comparator: Comparator<in T>): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList, comparator)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("This method may change its behavior soon. Use sortedBy() instead.", ReplaceWith("sortedBy(order)"))
public inline fun <T, R : Comparable<R>> Array<out T>.sortBy(crossinline order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, in descending order by results of specified [order] function.
*/
@Deprecated("This method may change its behavior soon. Use sortedByDescending() instead.", ReplaceWith("sortedByDescending(order)"))
public inline fun <T, R : Comparable<R>> Array<out T>.sortDescendingBy(crossinline order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareByDescending(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a list of all elements sorted according to their natural sort order.
*/
@@ -4865,195 +4761,6 @@ public fun ShortArray.sortedWith(comparator: Comparator<in Short>): List<Short>
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun <T : Comparable<T>> Array<out T>.toSortedList(): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun BooleanArray.toSortedList(): List<Boolean> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun ByteArray.toSortedList(): List<Byte> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun CharArray.toSortedList(): List<Char> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun DoubleArray.toSortedList(): List<Double> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun FloatArray.toSortedList(): List<Float> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun IntArray.toSortedList(): List<Int> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun LongArray.toSortedList(): List<Long> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun ShortArray.toSortedList(): List<Short> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <T, V : Comparable<V>> Array<out T>.toSortedListBy(order: (T) -> V): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> BooleanArray.toSortedListBy(order: (Boolean) -> V): List<Boolean> {
val sortedList = toArrayList()
val sortBy: Comparator<Boolean> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> ByteArray.toSortedListBy(order: (Byte) -> V): List<Byte> {
val sortedList = toArrayList()
val sortBy: Comparator<Byte> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> CharArray.toSortedListBy(order: (Char) -> V): List<Char> {
val sortedList = toArrayList()
val sortBy: Comparator<Char> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> DoubleArray.toSortedListBy(order: (Double) -> V): List<Double> {
val sortedList = toArrayList()
val sortBy: Comparator<Double> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> FloatArray.toSortedListBy(order: (Float) -> V): List<Float> {
val sortedList = toArrayList()
val sortBy: Comparator<Float> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> IntArray.toSortedListBy(order: (Int) -> V): List<Int> {
val sortedList = toArrayList()
val sortBy: Comparator<Int> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> LongArray.toSortedListBy(order: (Long) -> V): List<Long> {
val sortedList = toArrayList()
val sortBy: Comparator<Long> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <V : Comparable<V>> ShortArray.toSortedListBy(order: (Short) -> V): List<Short> {
val sortedList = toArrayList()
val sortBy: Comparator<Short> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns the Iterable that wraps the original array.
*/
@@ -710,14 +710,6 @@ public inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T>
return list
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun <T> Iterable<T>.reverse(): List<T> {
return reversed()
}
/**
* Returns a list with elements in reversed order.
*/
@@ -728,58 +720,6 @@ public fun <T> Iterable<T>.reversed(): List<T> {
return list
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("This method may change its behavior soon. Use sorted() instead.", ReplaceWith("sorted()"))
public fun <T : Comparable<T>> Iterable<T>.sort(): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a list of all elements, sorted by the specified [comparator].
*/
@Deprecated("This method may change its behavior soon. Use sortedWith() instead.", ReplaceWith("sortedWith(comparator)"))
public fun <T> Iterable<T>.sortBy(comparator: Comparator<in T>): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList, comparator)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("This method may change its behavior soon. Use sortedBy() instead.", ReplaceWith("sortedBy(order)"))
public inline fun <T, R : Comparable<R>> Iterable<T>.sortBy(crossinline order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a sorted list of all elements, in descending order.
*/
@Deprecated("This method may change its behavior soon. Use sortedDescending() instead.", ReplaceWith("sortedDescending()"))
public fun <T : Comparable<T>> Iterable<T>.sortDescending(): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList, comparator { x, y -> y.compareTo(x) })
return sortedList
}
/**
* Returns a sorted list of all elements, in descending order by results of specified [order] function.
*/
@Deprecated("This method may change its behavior soon. Use sortedByDescending() instead.", ReplaceWith("sortedByDescending(order)"))
public inline fun <T, R : Comparable<R>> Iterable<T>.sortDescendingBy(crossinline order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareByDescending(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns a list of all elements sorted according to their natural sort order.
*/
@@ -819,27 +759,6 @@ public fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {
return sortedList
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use sorted() instead.", ReplaceWith("sorted()"))
public fun <T : Comparable<T>> Iterable<T>.toSortedList(): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use sortedBy(order) instead.", ReplaceWith("sortedBy(order)"))
public fun <T, V : Comparable<V>> Iterable<T>.toSortedListBy(order: (T) -> V): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns an array of Boolean containing all of the elements of this collection.
*/
@@ -403,27 +403,6 @@ public fun <T> Sequence<T>.sortedWith(comparator: Comparator<in T>): Sequence<T>
}
}
/**
* Returns a sorted list of all elements.
*/
@Deprecated("Use asIterable().sorted() instead.", ReplaceWith("asIterable().sorted()"))
public fun <T : Comparable<T>> Sequence<T>.toSortedList(): List<T> {
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
}
/**
* Returns a sorted list of all elements, ordered by results of specified [order] function.
*/
@Deprecated("Use asIterable().sortedBy(order) instead.", ReplaceWith("asIterable().sortedBy(order)"))
public fun <T, V : Comparable<V>> Sequence<T>.toSortedListBy(order: (T) -> V): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
}
/**
* Returns an [ArrayList] of all elements.
*/
@@ -341,14 +341,6 @@ public inline fun String.takeWhile(predicate: (Char) -> Boolean): String {
return this
}
/**
* Returns a list with elements in reversed order.
*/
@Deprecated("reverse will change its behavior soon. Use reversed() instead.", ReplaceWith("reversed()"))
public fun String.reverse(): String {
return reversed()
}
/**
* Returns a string with characters in reversed order.
*/
@@ -5,18 +5,18 @@ import templates.Family.*
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("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." }
@@ -278,177 +278,128 @@ fun ordering(): List<GenericFunction> {
}
}
templates add f("sort()") {
doc {
"""
Returns a sorted list of all elements.
"""
}
returns("List<T>")
typeParam("T : Comparable<T>")
deprecate("This method may change its behavior soon. Use sorted() instead.")
deprecateReplacement("sorted()")
body {
"""
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
"""
}
// templates add f("sort()") {
// doc {
// """
// Returns a sorted list of all elements.
// """
// }
// returns("List<T>")
// typeParam("T : Comparable<T>")
// deprecate("This method may change its behavior soon. Use sorted() instead.")
// deprecateReplacement("sorted()")
// body {
// """
// val sortedList = toArrayList()
// java.util.Collections.sort(sortedList)
// return sortedList
// """
// }
//
// exclude(Sequences)
// exclude(ArraysOfPrimitives)
// exclude(ArraysOfObjects)
// exclude(Strings)
// }
exclude(Sequences)
exclude(ArraysOfPrimitives)
exclude(ArraysOfObjects)
exclude(Strings)
}
// templates add f("sortDescending()") {
// doc {
// """
// Returns a sorted list of all elements, in descending order.
// """
// }
// deprecate("This method may change its behavior soon. Use sortedDescending() instead.")
// deprecateReplacement("sortedDescending()")
// returns("List<T>")
// typeParam("T : Comparable<T>")
// body {
// """
// val sortedList = toArrayList()
// java.util.Collections.sort(sortedList, comparator { x, y -> y.compareTo(x) })
// return sortedList
// """
// }
//
// exclude(Sequences)
// exclude(ArraysOfPrimitives)
// exclude(ArraysOfObjects)
// exclude(Strings)
// }
templates add f("toSortedList()") {
doc {
"""
Returns a sorted list of all elements.
"""
}
returns("List<T>")
typeParam("T : Comparable<T>")
deprecate("Use sorted() instead.")
deprecateReplacement("sorted()")
// templates add f("sortBy(crossinline order: (T) -> R)") {
// inline(true)
//
// doc {
// """
// Returns a sorted list of all elements, ordered by results of specified [order] function.
// """
// }
// deprecate("This method may change its behavior soon. Use sortedBy() instead.")
// deprecateReplacement("sortedBy(order)")
// returns("List<T>")
// typeParam("R : Comparable<R>")
// body {
// """
// val sortedList = toArrayList()
// val sortBy: Comparator<T> = compareBy(order)
// java.util.Collections.sort(sortedList, sortBy)
// return sortedList
// """
// }
//
// exclude(Sequences)
// exclude(ArraysOfPrimitives)
// exclude(Strings)
// }
deprecate("Use asIterable().sorted() instead.", Sequences)
deprecateReplacement("asIterable().sorted()", Sequences)
body {
"""
val sortedList = toArrayList()
java.util.Collections.sort(sortedList)
return sortedList
"""
}
only(Sequences, ArraysOfObjects, ArraysOfPrimitives, Iterables)
}
// templates add f("sortDescendingBy(crossinline order: (T) -> R)") {
// inline(true)
//
// doc {
// """
// Returns a sorted list of all elements, in descending order by results of specified [order] function.
// """
// }
// deprecate("This method may change its behavior soon. Use sortedByDescending() instead.")
// deprecateReplacement("sortedByDescending(order)")
// returns("List<T>")
// typeParam("R : Comparable<R>")
// body {
// """
// val sortedList = toArrayList()
// val sortBy: Comparator<T> = compareByDescending(order)
// java.util.Collections.sort(sortedList, sortBy)
// return sortedList
// """
// }
//
// exclude(Sequences)
// exclude(ArraysOfPrimitives)
// exclude(Strings)
// }
templates add f("sortDescending()") {
doc {
"""
Returns a sorted list of all elements, in descending order.
"""
}
deprecate("This method may change its behavior soon. Use sortedDescending() instead.")
deprecateReplacement("sortedDescending()")
returns("List<T>")
typeParam("T : Comparable<T>")
body {
"""
val sortedList = toArrayList()
java.util.Collections.sort(sortedList, comparator { x, y -> y.compareTo(x) })
return sortedList
"""
}
exclude(Sequences)
exclude(ArraysOfPrimitives)
exclude(ArraysOfObjects)
exclude(Strings)
}
templates add f("sortBy(crossinline order: (T) -> R)") {
inline(true)
doc {
"""
Returns a sorted list of all elements, ordered by results of specified [order] function.
"""
}
deprecate("This method may change its behavior soon. Use sortedBy() instead.")
deprecateReplacement("sortedBy(order)")
returns("List<T>")
typeParam("R : Comparable<R>")
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
"""
}
exclude(Sequences)
exclude(ArraysOfPrimitives)
exclude(Strings)
}
templates add f("toSortedListBy(order: (T) -> V)") {
doc {
"""
Returns a sorted list of all elements, ordered by results of specified [order] function.
"""
}
returns("List<T>")
deprecate("Use sortedBy(order) instead.")
deprecateReplacement("sortedBy(order)")
deprecate("Use asIterable().sortedBy(order) instead.", Sequences)
deprecateReplacement("asIterable().sortedBy(order)", Sequences)
typeParam("T")
typeParam("V : Comparable<V>")
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareBy(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
"""
}
only(Sequences, ArraysOfObjects, ArraysOfPrimitives, Iterables)
}
templates add f("sortDescendingBy(crossinline order: (T) -> R)") {
inline(true)
doc {
"""
Returns a sorted list of all elements, in descending order by results of specified [order] function.
"""
}
deprecate("This method may change its behavior soon. Use sortedByDescending() instead.")
deprecateReplacement("sortedByDescending(order)")
returns("List<T>")
typeParam("R : Comparable<R>")
body {
"""
val sortedList = toArrayList()
val sortBy: Comparator<T> = compareByDescending(order)
java.util.Collections.sort(sortedList, sortBy)
return sortedList
"""
}
exclude(Sequences)
exclude(ArraysOfPrimitives)
exclude(Strings)
}
templates add f("sortBy(comparator: Comparator<in T>)") {
doc {
"""
Returns a list of all elements, sorted by the specified [comparator].
"""
}
returns("List<T>")
deprecate("This method may change its behavior soon. Use sortedWith() instead.")
deprecateReplacement("sortedWith(comparator)")
body {
"""
val sortedList = toArrayList()
java.util.Collections.sort(sortedList, comparator)
return sortedList
"""
}
exclude(Sequences)
exclude(ArraysOfPrimitives)
exclude(Strings)
}
// templates add f("sortBy(comparator: Comparator<in T>)") {
// doc {
// """
// Returns a list of all elements, sorted by the specified [comparator].
// """
// }
// returns("List<T>")
// deprecate("This method may change its behavior soon. Use sortedWith() instead.")
// deprecateReplacement("sortedWith(comparator)")
// body {
// """
// val sortedList = toArrayList()
// java.util.Collections.sort(sortedList, comparator)
// return sortedList
// """
// }
//
// exclude(Sequences)
// exclude(ArraysOfPrimitives)
// exclude(Strings)
// }
return templates
}