Make all remaining deprecations to be errors.

This commit is contained in:
Ilya Gorbunov
2016-01-26 22:11:56 +03:00
parent 263e1b4b5d
commit d46501e11b
19 changed files with 144 additions and 193 deletions
+45 -45
View File
@@ -6019,7 +6019,7 @@ public inline fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateTo(dest
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun <T> Array<out T>.toArrayList(): ArrayList<T> {
return ArrayList(this.asCollection())
}
@@ -6027,7 +6027,7 @@ public fun <T> Array<out T>.toArrayList(): ArrayList<T> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun BooleanArray.toArrayList(): ArrayList<Boolean> {
val list = ArrayList<Boolean>(size)
for (item in this) list.add(item)
@@ -6037,7 +6037,7 @@ public fun BooleanArray.toArrayList(): ArrayList<Boolean> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun ByteArray.toArrayList(): ArrayList<Byte> {
val list = ArrayList<Byte>(size)
for (item in this) list.add(item)
@@ -6047,7 +6047,7 @@ public fun ByteArray.toArrayList(): ArrayList<Byte> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun CharArray.toArrayList(): ArrayList<Char> {
val list = ArrayList<Char>(size)
for (item in this) list.add(item)
@@ -6057,7 +6057,7 @@ public fun CharArray.toArrayList(): ArrayList<Char> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun DoubleArray.toArrayList(): ArrayList<Double> {
val list = ArrayList<Double>(size)
for (item in this) list.add(item)
@@ -6067,7 +6067,7 @@ public fun DoubleArray.toArrayList(): ArrayList<Double> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun FloatArray.toArrayList(): ArrayList<Float> {
val list = ArrayList<Float>(size)
for (item in this) list.add(item)
@@ -6077,7 +6077,7 @@ public fun FloatArray.toArrayList(): ArrayList<Float> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun IntArray.toArrayList(): ArrayList<Int> {
val list = ArrayList<Int>(size)
for (item in this) list.add(item)
@@ -6087,7 +6087,7 @@ public fun IntArray.toArrayList(): ArrayList<Int> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun LongArray.toArrayList(): ArrayList<Long> {
val list = ArrayList<Long>(size)
for (item in this) list.add(item)
@@ -6097,7 +6097,7 @@ public fun LongArray.toArrayList(): ArrayList<Long> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun ShortArray.toArrayList(): ArrayList<Short> {
val list = ArrayList<Short>(size)
for (item in this) list.add(item)
@@ -6324,7 +6324,7 @@ public fun ShortArray.toList(): List<Short> {
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <T, K, V> Array<out T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6333,7 +6333,7 @@ public inline fun <T, K, V> Array<out T>.toMap(selector: (T) -> K, transform: (T
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> BooleanArray.toMap(selector: (Boolean) -> K, transform: (Boolean) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6342,7 +6342,7 @@ public inline fun <K, V> BooleanArray.toMap(selector: (Boolean) -> K, transform:
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> ByteArray.toMap(selector: (Byte) -> K, transform: (Byte) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6351,7 +6351,7 @@ public inline fun <K, V> ByteArray.toMap(selector: (Byte) -> K, transform: (Byte
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> CharArray.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6360,7 +6360,7 @@ public inline fun <K, V> CharArray.toMap(selector: (Char) -> K, transform: (Char
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> DoubleArray.toMap(selector: (Double) -> K, transform: (Double) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6369,7 +6369,7 @@ public inline fun <K, V> DoubleArray.toMap(selector: (Double) -> K, transform: (
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> FloatArray.toMap(selector: (Float) -> K, transform: (Float) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6378,7 +6378,7 @@ public inline fun <K, V> FloatArray.toMap(selector: (Float) -> K, transform: (Fl
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> IntArray.toMap(selector: (Int) -> K, transform: (Int) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6387,7 +6387,7 @@ public inline fun <K, V> IntArray.toMap(selector: (Int) -> K, transform: (Int) -
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> LongArray.toMap(selector: (Long) -> K, transform: (Long) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -6396,151 +6396,151 @@ public inline fun <K, V> LongArray.toMap(selector: (Long) -> K, transform: (Long
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> ShortArray.toMap(selector: (Short) -> K, transform: (Short) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <T, K, V> Array<out T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> BooleanArray.toMap(transform: (Boolean) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> ByteArray.toMap(transform: (Byte) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> CharArray.toMap(transform: (Char) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> DoubleArray.toMap(transform: (Double) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> FloatArray.toMap(transform: (Float) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> IntArray.toMap(transform: (Int) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> LongArray.toMap(transform: (Long) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> ShortArray.toMap(transform: (Short) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <T, K> Array<out T>.toMapBy(selector: (T) -> K): Map<K, T> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> BooleanArray.toMapBy(selector: (Boolean) -> K): Map<K, Boolean> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> ByteArray.toMapBy(selector: (Byte) -> K): Map<K, Byte> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> CharArray.toMapBy(selector: (Char) -> K): Map<K, Char> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> DoubleArray.toMapBy(selector: (Double) -> K): Map<K, Double> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> FloatArray.toMapBy(selector: (Float) -> K): Map<K, Float> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> IntArray.toMapBy(selector: (Int) -> K): Map<K, Int> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> LongArray.toMapBy(selector: (Long) -> K): Map<K, Long> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> ShortArray.toMapBy(selector: (Short) -> K): Map<K, Short> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <T, K, V> Array<out T>.toMapBy(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> BooleanArray.toMapBy(selector: (Boolean) -> K, transform: (Boolean) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> ByteArray.toMapBy(selector: (Byte) -> K, transform: (Byte) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> CharArray.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> DoubleArray.toMapBy(selector: (Double) -> K, transform: (Double) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> FloatArray.toMapBy(selector: (Float) -> K, transform: (Float) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> IntArray.toMapBy(selector: (Int) -> K, transform: (Int) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> LongArray.toMapBy(selector: (Long) -> K, transform: (Long) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> ShortArray.toMapBy(selector: (Short) -> K, transform: (Short) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -983,7 +983,7 @@ public inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun <T> Collection<T>.toArrayList(): ArrayList<T> {
return ArrayList(this)
}
@@ -991,10 +991,10 @@ public fun <T> Collection<T>.toArrayList(): ArrayList<T> {
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun <T> Iterable<T>.toArrayList(): ArrayList<T> {
if (this is Collection<T>)
return this.toArrayList()
return ArrayList(this)
return toCollection(ArrayList<T>())
}
@@ -1026,23 +1026,23 @@ public fun <T> Iterable<T>.toList(): List<T> {
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given collection.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <T, K, V> Iterable<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <T, K, V> Iterable<T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <T, K> Iterable<T>.toMapBy(selector: (T) -> K): Map<K, T> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <T, K, V> Iterable<T>.toMapBy(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
return associateBy(selector, transform)
}
+5 -5
View File
@@ -489,7 +489,7 @@ public inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateTo(
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun <T> Sequence<T>.toArrayList(): ArrayList<T> {
return toCollection(ArrayList<T>())
}
@@ -522,23 +522,23 @@ public fun <T> Sequence<T>.toList(): List<T> {
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given sequence.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <T, K, V> Sequence<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <T, K, V> Sequence<T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <T, K> Sequence<T>.toMapBy(selector: (T) -> K): Map<K, T> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <T, K, V> Sequence<T>.toMapBy(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
return associateBy(selector, transform)
}
+5 -5
View File
@@ -561,7 +561,7 @@ public inline fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateTo(de
/**
* Returns an [ArrayList] of all characters.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"))
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun CharSequence.toArrayList(): ArrayList<Char> {
return toCollection(ArrayList<Char>(length))
}
@@ -594,23 +594,23 @@ public fun CharSequence.toList(): List<Char> {
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given char sequence.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> CharSequence.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR)
@kotlin.jvm.JvmName("toMapOfPairs")
public inline fun <K, V> CharSequence.toMap(transform: (Char) -> Pair<K, V>): Map<K, V> {
return associate(transform)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR)
public inline fun <K> CharSequence.toMapBy(selector: (Char) -> K): Map<K, Char> {
return associateBy(selector)
}
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR)
public inline fun <K, V> CharSequence.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
return associateBy(selector, transform)
}
@@ -75,11 +75,11 @@ public fun <T> listOf(element: T): List<T> = Collections.singletonList(element)
/** Returns a new [LinkedList] with the given elements. */
@JvmVersion
@Deprecated("Use LinkedList constructor.", ReplaceWith("LinkedList(listOf(*elements))", "java.util.LinkedList"))
@Deprecated("Use LinkedList constructor.", ReplaceWith("LinkedList(listOf(*elements))", "java.util.LinkedList"), level = DeprecationLevel.ERROR)
public fun <T> linkedListOf(vararg elements: T): LinkedList<T>
= if (elements.size == 0) LinkedList() else LinkedList(ArrayAsCollection(elements))
@Deprecated("Use LinkedList constructor.", ReplaceWith("LinkedList<T>()", "java.util.LinkedList"))
@Deprecated("Use LinkedList constructor.", ReplaceWith("LinkedList<T>()", "java.util.LinkedList"), level = DeprecationLevel.ERROR)
public fun <T> linkedListOf() = LinkedList<T>()
@@ -12,17 +12,8 @@ import java.util.*
*
* @throws NoSuchElementException when the map doesn't contain value for the specified key and no implicit default was provided for that map.
*/
@Deprecated("This function is used to support property delegation to map with defaults and will become internal soon.")
public fun <K, V: Any> Map<K, V>.getOrImplicitDefault(key: K): V {
if (this is MapWithDefault)
return this.getOrImplicitDefault(key)
return getOrElseNullable(key, { throw NoSuchElementException("Key $key is missing in the map.") })
}
@kotlin.jvm.JvmName("getOrImplicitDefaultNullable")
@Deprecated("This function is used to support property delegation to map with defaults and will become internal soon.")
public fun <K, V> Map<K, V>.getOrImplicitDefault(key: K): V {
internal fun <K, V> Map<K, V>.getOrImplicitDefault(key: K): V {
if (this is MapWithDefault)
return this.getOrImplicitDefault(key)
@@ -31,7 +22,7 @@ public fun <K, V> Map<K, V>.getOrImplicitDefault(key: K): V {
/**
* Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue].
* This implicit default value is used when [getOrImplicitDefault] is called on the returned map,
* This implicit default value is used when properties are delegated to the returned map,
* and that map doesn't contain value for the key specified.
*
* When this map already have an implicit default value provided with a former call to [withDefault], it is being replaced by this call.
@@ -44,7 +35,7 @@ public fun <K, V> Map<K, V>.withDefault(defaultValue: (key: K) -> V): Map<K, V>
/**
* Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue].
* This implicit default value is used when [getOrImplicitDefault] is called on the returned map,
* This implicit default value is used when properties are delegated to the returned map,
* and that map doesn't contain value for the key specified.
*
* When this map already have an implicit default value provided with a former call to [withDefault], it is being replaced by this call.
+13 -13
View File
@@ -392,7 +392,7 @@ public fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(destina
/**
* Converts this [Map] to a [LinkedHashMap], maintaining the insertion order of elements added to that map afterwards.
*/
@Deprecated("It may be too late to convert map this map to linked map, if you care about the order use the ordered map from the beginning.", ReplaceWith("LinkedHashMap(this)", "java.util.LinkedHashMap"))
@Deprecated("It may be too late to convert map this map to linked map, if you care about the order use the ordered map from the beginning.", ReplaceWith("LinkedHashMap(this)", "java.util.LinkedHashMap"), level = DeprecationLevel.ERROR)
public fun <K, V> Map<K, V>.toLinkedMap(): MutableMap<K, V> = LinkedHashMap(this)
/**
@@ -464,35 +464,35 @@ public operator fun <K, V> MutableMap<in K, in V>.plusAssign(map: Map<K, V>) {
/**
* Creates a new read-only map by removing a [key] from this map.
*/
@Deprecated("This operation will be removed soon.")
@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= key.", level = DeprecationLevel.ERROR)
public operator fun <K, V> Map<K, V>.minus(key: K): Map<K, V>
= this.toLinkedMap().apply { minusAssign(key) }
= LinkedHashMap(this).apply { keys.remove(key) }
/**
* Creates a new read-only map by removing a collection of [keys] from this map.
*/
@Deprecated("This operation will be removed soon.")
@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= keys.", level = DeprecationLevel.ERROR)
public operator fun <K, V> Map<K, V>.minus(keys: Iterable<K>): Map<K, V>
= this.toLinkedMap().apply { minusAssign(keys) }
= LinkedHashMap(this).apply { for (key in keys) remove(key) }
/**
* Creates a new read-only map by removing a array of [keys] from this map.
*/
@Deprecated("This operation will be removed soon.")
@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= keys.", level = DeprecationLevel.ERROR)
public operator fun <K, V> Map<K, V>.minus(keys: Array<K>): Map<K, V>
= this.toLinkedMap().apply { minusAssign(keys) }
= LinkedHashMap(this).apply { for (key in keys) remove(key) }
/**
* Creates a new read-only map by removing a sequence of [keys] from this map.
*/
@Deprecated("This operation will be removed soon.")
@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= keys.", level = DeprecationLevel.ERROR)
public operator fun <K, V> Map<K, V>.minus(keys: Sequence<K>): Map<K, V>
= this.toLinkedMap().apply { minusAssign(keys) }
= LinkedHashMap(this).apply { for (key in keys) remove(key) }
/**
* Removes the given [key] from this mutable map.
*/
@Deprecated("This operation will be removed soon, use remove(key) instead.", ReplaceWith("this.keys -= key"))
@Deprecated("This operation will be removed soon, use remove(key) instead.", ReplaceWith("this.keys -= key"), level = DeprecationLevel.ERROR)
public operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) {
remove(key)
}
@@ -500,7 +500,7 @@ public operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) {
/**
* Removes all the given [keys] from this mutable map.
*/
@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"))
@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"), level = DeprecationLevel.ERROR)
public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {
for (key in keys) remove(key)
}
@@ -508,7 +508,7 @@ public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {
/**
* Removes all the given [keys] from this mutable map.
*/
@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"))
@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"), level = DeprecationLevel.ERROR)
public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<K>) {
for (key in keys) remove(key)
}
@@ -516,7 +516,7 @@ public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<K>) {
/**
* Removes all the given [keys] from this mutable map.
*/
@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"))
@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"), level = DeprecationLevel.ERROR)
public operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Sequence<K>) {
for (key in keys) remove(key)
}
@@ -488,7 +488,7 @@ public fun <T : Any> generateSequence(nextFunction: () -> T?): Sequence<T> {
return GeneratorSequence(nextFunction, { nextFunction() }).constrainOnce()
}
@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(nextFunction)"))
@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(nextFunction)"), level = DeprecationLevel.ERROR)
public fun <T : Any> sequence(nextFunction: () -> T?): Sequence<T> = generateSequence(nextFunction)
/**
@@ -504,7 +504,7 @@ public fun <T : Any> generateSequence(seed: T?, nextFunction: (T) -> T?): Sequen
else
GeneratorSequence({ seed }, nextFunction)
@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(initialValue, nextFunction)"))
@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(initialValue, nextFunction)"), level = DeprecationLevel.ERROR)
@kotlin.internal.LowPriorityInOverloadResolution
public fun <T : Any> sequence(initialValue: T?, nextFunction: (T) -> T?): Sequence<T> = generateSequence(initialValue, nextFunction)
@@ -517,5 +517,5 @@ public fun <T: Any> generateSequence(seedFunction: () -> T?, nextFunction: (T) -
GeneratorSequence(seedFunction, nextFunction)
@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(initialValueFunction, nextFunction)"))
@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(initialValueFunction, nextFunction)"), level = DeprecationLevel.ERROR)
public fun <T: Any> sequence(initialValueFunction: () -> T?, nextFunction: (T) -> T?): Sequence<T> = generateSequence(initialValueFunction, nextFunction)
@@ -60,7 +60,6 @@ public class FileTreeWalk private constructor(
/** Abstract class that encapsulates directory visiting in some order, beginning from a given [rootDir] */
private abstract class DirectoryState(rootDir: File): WalkState(rootDir) {
init {
@Suppress("DEPRECATION")
if (ASSERTIONS_ENABLED)
assert(rootDir.isDirectory) { "rootDir must be verified to be directory beforehand." }
}
@@ -208,7 +207,6 @@ public class FileTreeWalk private constructor(
private var visited: Boolean = false
init {
@Suppress("DEPRECATION")
if (ASSERTIONS_ENABLED)
assert(rootFile.isFile) { "rootFile must be verified to be file beforehand." }
}
@@ -87,7 +87,7 @@ public fun File.toRelativeString(base: File): String
*/
public fun File.relativeTo(base: File): File = File(this.toRelativeString(base))
@Deprecated("Use relativeTo instead.", ReplaceWith("this.relativeTo(base)"), level = DeprecationLevel.WARNING)
@Deprecated("Use relativeTo instead.", ReplaceWith("this.relativeTo(base)"), level = DeprecationLevel.ERROR)
public fun File.relativeToFile(base: File): File = File(this.toRelativeString(base))
@@ -445,7 +445,7 @@ public fun CharSequence.repeat(n: Int): String {
* Appends the contents of this char sequence, excluding the first characters that satisfy the given [predicate],
* to the given Appendable.
*/
@Deprecated("This function will be removed soon.", ReplaceWith("result.append(this.dropWhile(predicate))"))
@Deprecated("This function will be removed soon.", ReplaceWith("result.append(this.dropWhile(predicate))"), level = DeprecationLevel.ERROR)
public inline fun <T : Appendable> CharSequence.dropWhileTo(result: T, predicate: (Char) -> Boolean): T {
var start = true
for (element in this) {
@@ -462,7 +462,7 @@ public inline fun <T : Appendable> CharSequence.dropWhileTo(result: T, predicate
/**
* Appends the first characters from this char sequence that satisfy the given [predicate] to the given Appendable.
*/
@Deprecated("This function will be removed soon.", ReplaceWith("result.append(this.takeWhile(predicate))"))
@Deprecated("This function will be removed soon.", ReplaceWith("result.append(this.takeWhile(predicate))"), level = DeprecationLevel.ERROR)
public inline fun <T : Appendable> CharSequence.takeWhileTo(result: T, predicate: (Char) -> Boolean): T {
for (c in this) if (predicate(c)) result.append(c) else break
return result
@@ -5,8 +5,7 @@ package kotlin
private object _Assertions
@Deprecated("Not supposed to be used directly, exposed to make assert() inlinable.")
public val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus()
internal val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus()
/**
* Throws an [AssertionError] if the [value] is false
@@ -21,7 +20,7 @@ public fun assert(value: Boolean) {
* and runtime assertions have been enabled on the JVM using the *-ea* JVM option.
*/
public inline fun assert(value: Boolean, lazyMessage: () -> Any) {
@Suppress("DEPRECATION")
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
if (ASSERTIONS_ENABLED) {
if (!value) {
val message = lazyMessage()
@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:kotlin.jvm.JvmName("ComparisonsKt")
@file:Suppress("DEPRECATION_ERROR")
package kotlin
@@ -25,7 +26,7 @@ import java.util.Comparator
* objects. As soon as the [Comparable] instances returned by a function for [a] and [b] values do not
* compare as equal, the result of that comparison is returned.
*/
@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, *selectors)", "kotlin.comparisons.compareValuesBy"))
@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, *selectors)", "kotlin.comparisons.compareValuesBy"), level = DeprecationLevel.ERROR)
public fun <T> compareValuesBy(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int {
require(selectors.size > 0)
for (fn in selectors) {
@@ -42,7 +43,7 @@ public fun <T> compareValuesBy(a: T, b: T, vararg selectors: (T) -> Comparable<*
* The function is applied to the given values [a] and [b] and return [Comparable] objects.
* The result of comparison of these [Comparable] instances is returned.
*/
@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, selector)", "kotlin.comparisons.compareValuesBy"))
@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, selector)", "kotlin.comparisons.compareValuesBy"), level = DeprecationLevel.ERROR)
public inline fun <T> compareValuesBy(a: T, b: T, selector: (T) -> Comparable<*>?): Int {
return compareValues(selector(a), selector(b))
}
@@ -52,7 +53,7 @@ public inline fun <T> compareValuesBy(a: T, b: T, selector: (T) -> Comparable<*>
* The function is applied to the given values [a] and [b] and return objects of type K which are then being
* compared with the given [comparator].
*/
@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, comparator, selector)", "kotlin.comparisons.compareValuesBy"))
@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, comparator, selector)", "kotlin.comparisons.compareValuesBy"), level = DeprecationLevel.ERROR)
public inline fun <T, K> compareValuesBy(a: T, b: T, comparator: Comparator<in K>, selector: (T) -> K): Int {
return comparator.compare(selector(a), selector(b))
}
@@ -70,7 +71,7 @@ public inline fun <T, K> compareValuesBy(a: T, b: T, comparator: Comparator<in K
/**
* Compares two nullable [Comparable] values. Null is considered less than any value.
*/
@Deprecated("Use compareValues from kotlin.comparisons package.", ReplaceWith("compareValues(a, b)", "kotlin.comparisons.compareValues"))
@Deprecated("Use compareValues from kotlin.comparisons package.", ReplaceWith("compareValues(a, b)", "kotlin.comparisons.compareValues"), level = DeprecationLevel.ERROR)
public fun <T : Comparable<*>> compareValues(a: T?, b: T?): Int {
if (a === b) return 0
if (a == null) return -1
@@ -85,7 +86,7 @@ public fun <T : Comparable<*>> compareValues(a: T?, b: T?): Int {
* objects. As soon as the [Comparable] instances returned by a function for `a` and `b` values do not
* compare as equal, the result of that comparison is returned from the [Comparator].
*/
@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(*selectors)", "kotlin.comparisons.compareBy"))
@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(*selectors)", "kotlin.comparisons.compareBy"), level = DeprecationLevel.ERROR)
public fun <T> compareBy(vararg selectors: (T) -> Comparable<*>?): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, *selectors)
@@ -97,7 +98,7 @@ public fun <T> compareBy(vararg selectors: (T) -> Comparable<*>?): Comparator<T>
/**
* Creates a comparator using the function to transform value to a [Comparable] instance for comparison.
*/
@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(selector)", "kotlin.comparisons.compareBy"))
@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(selector)", "kotlin.comparisons.compareBy"), level = DeprecationLevel.ERROR)
inline public fun <T> compareBy(crossinline selector: (T) -> Comparable<*>?): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, selector)
@@ -108,7 +109,7 @@ inline public fun <T> compareBy(crossinline selector: (T) -> Comparable<*>?): Co
* Creates a comparator using the [selector] function to transform values being compared and then applying
* the specified [comparator] to compare transformed values.
*/
@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(comparator, selector)", "kotlin.comparisons.compareBy"))
@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(comparator, selector)", "kotlin.comparisons.compareBy"), level = DeprecationLevel.ERROR)
inline public fun <T, K> compareBy(comparator: Comparator<in K>, crossinline selector: (T) -> K): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, comparator, selector)
@@ -118,7 +119,7 @@ inline public fun <T, K> compareBy(comparator: Comparator<in K>, crossinline sel
/**
* Creates a descending comparator using the function to transform value to a [Comparable] instance for comparison.
*/
@Deprecated("Use compareByDescending from kotlin.comparisons package.", ReplaceWith("compareByDescending(selector)", "kotlin.comparisons.compareByDescending"))
@Deprecated("Use compareByDescending from kotlin.comparisons package.", ReplaceWith("compareByDescending(selector)", "kotlin.comparisons.compareByDescending"), level = DeprecationLevel.ERROR)
inline public fun <T> compareByDescending(crossinline selector: (T) -> Comparable<*>?): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int = compareValuesBy(b, a, selector)
@@ -131,7 +132,7 @@ inline public fun <T> compareByDescending(crossinline selector: (T) -> Comparabl
*
* Note that an order of [comparator] is reversed by this wrapper.
*/
@Deprecated("Use compareByDescending from kotlin.comparisons package.", ReplaceWith("compareByDescending(comparator, selector)", "kotlin.comparisons.compareByDescending"))
@Deprecated("Use compareByDescending from kotlin.comparisons package.", ReplaceWith("compareByDescending(comparator, selector)", "kotlin.comparisons.compareByDescending"), level = DeprecationLevel.ERROR)
inline public fun <T, K> compareByDescending(comparator: Comparator<in K>, crossinline selector: (T) -> K): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int = compareValuesBy(b, a, comparator, selector)
@@ -142,7 +143,7 @@ inline public fun <T, K> compareByDescending(comparator: Comparator<in K>, cross
* Creates a comparator comparing values after the primary comparator defined them equal. It uses
* the function to transform value to a [Comparable] instance for comparison.
*/
@Deprecated("Use thenBy from kotlin.comparisons package.", ReplaceWith("this.thenBy(selector)", "kotlin.comparisons.thenBy"))
@Deprecated("Use thenBy from kotlin.comparisons package.", ReplaceWith("this.thenBy(selector)", "kotlin.comparisons.thenBy"), level = DeprecationLevel.ERROR)
inline public fun <T> Comparator<T>.thenBy(crossinline selector: (T) -> Comparable<*>?): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -156,7 +157,7 @@ inline public fun <T> Comparator<T>.thenBy(crossinline selector: (T) -> Comparab
* Creates a comparator comparing values after the primary comparator defined them equal. It uses
* the [selector] function to transform values and then compares them with the given [comparator].
*/
@Deprecated("Use thenBy from kotlin.comparisons package.", ReplaceWith("this.thenBy(comparator, selector)", "kotlin.comparisons.thenBy"))
@Deprecated("Use thenBy from kotlin.comparisons package.", ReplaceWith("this.thenBy(comparator, selector)", "kotlin.comparisons.thenBy"), level = DeprecationLevel.ERROR)
inline public fun <T, K> Comparator<T>.thenBy(comparator: Comparator<in K>, crossinline selector: (T) -> K): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -170,7 +171,7 @@ inline public fun <T, K> Comparator<T>.thenBy(comparator: Comparator<in K>, cros
* Creates a descending comparator using the primary comparator and
* the function to transform value to a [Comparable] instance for comparison.
*/
@Deprecated("Use thenByDescending from kotlin.comparisons package.", ReplaceWith("this.thenByDescending(selector)", "kotlin.comparisons.thenByDescending"))
@Deprecated("Use thenByDescending from kotlin.comparisons package.", ReplaceWith("this.thenByDescending(selector)", "kotlin.comparisons.thenByDescending"), level = DeprecationLevel.ERROR)
inline public fun <T> Comparator<T>.thenByDescending(crossinline selector: (T) -> Comparable<*>?): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -184,7 +185,7 @@ inline public fun <T> Comparator<T>.thenByDescending(crossinline selector: (T) -
* Creates a descending comparator comparing values after the primary comparator defined them equal. It uses
* the [selector] function to transform values and then compares them with the given [comparator].
*/
@Deprecated("Use thenByDescending from kotlin.comparisons package.", ReplaceWith("this.thenByDescending(comparator, selector)", "kotlin.comparisons.thenByDescending"))
@Deprecated("Use thenByDescending from kotlin.comparisons package.", ReplaceWith("this.thenByDescending(comparator, selector)", "kotlin.comparisons.thenByDescending"), level = DeprecationLevel.ERROR)
inline public fun <T, K> Comparator<T>.thenByDescending(comparator: Comparator<in K>, crossinline selector: (T) -> K): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -197,13 +198,13 @@ inline public fun <T, K> Comparator<T>.thenByDescending(comparator: Comparator<i
/**
* Creates a comparator using the function to calculate a result of comparison.
*/
@Deprecated("Use Comparator SAM-constructor instead.", ReplaceWith("Comparator(comparison)", "java.util.Comparator"))
@Deprecated("Use Comparator SAM-constructor instead.", ReplaceWith("Comparator(comparison)", "java.util.Comparator"), level = DeprecationLevel.ERROR)
inline public fun <T> comparator(crossinline comparison: (T, T) -> Int) = Comparator<T> { a, b -> comparison(a, b) }
/**
* Creates a comparator using the primary comparator and function to calculate a result of comparison.
*/
@Deprecated("Use thenComparator from kotlin.comparisons package.", ReplaceWith("this.thenComparator(comparison)", "kotlin.comparisons.thenComparator"))
@Deprecated("Use thenComparator from kotlin.comparisons package.", ReplaceWith("this.thenComparator(comparison)", "kotlin.comparisons.thenComparator"), level = DeprecationLevel.ERROR)
inline public fun <T> Comparator<T>.thenComparator(crossinline comparison: (T, T) -> Int): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -217,7 +218,7 @@ inline public fun <T> Comparator<T>.thenComparator(crossinline comparison: (T, T
* Combines this comparator and the given [comparator] such that the latter is applied only
* when the former considered values equal.
*/
@Deprecated("Use then from kotlin.comparisons package.", ReplaceWith("this.then(comparator)", "kotlin.comparisons.then"))
@Deprecated("Use then from kotlin.comparisons package.", ReplaceWith("this.then(comparator)", "kotlin.comparisons.then"), level = DeprecationLevel.ERROR)
public infix fun <T> Comparator<T>.then(comparator: Comparator<in T>): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -231,7 +232,7 @@ public infix fun <T> Comparator<T>.then(comparator: Comparator<in T>): Comparato
* Combines this comparator and the given [comparator] such that the latter is applied only
* when the former considered values equal.
*/
@Deprecated("Use thenDescending from kotlin.comparisons package.", ReplaceWith("this.thenDescending(comparator)", "kotlin.comparisons.thenDescending"))
@Deprecated("Use thenDescending from kotlin.comparisons package.", ReplaceWith("this.thenDescending(comparator)", "kotlin.comparisons.thenDescending"), level = DeprecationLevel.ERROR)
public infix fun <T> Comparator<T>.thenDescending(comparator: Comparator<in T>): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
@@ -246,7 +247,7 @@ public infix fun <T> Comparator<T>.thenDescending(comparator: Comparator<in T>):
* Extends the given [comparator] of non-nullable values to a comparator of nullable values
* considering `null` value less than any other value.
*/
@Deprecated("Use nullsFirst from kotlin.comparisons package.", ReplaceWith("nullsFirst(comparator)", "kotlin.comparisons.nullsFirst"))
@Deprecated("Use nullsFirst from kotlin.comparisons package.", ReplaceWith("nullsFirst(comparator)", "kotlin.comparisons.nullsFirst"), level = DeprecationLevel.ERROR)
public fun <T: Any> nullsFirst(comparator: Comparator<in T>): Comparator<T?> {
return object: Comparator<T?> {
override fun compare(a: T?, b: T?): Int {
@@ -262,14 +263,14 @@ public fun <T: Any> nullsFirst(comparator: Comparator<in T>): Comparator<T?> {
* Provides a comparator of nullable [Comparable] values
* considering `null` value less than any other value.
*/
@Deprecated("Use nullsFirst from kotlin.comparisons package.", ReplaceWith("nullsFirst<T>()", "kotlin.comparisons.nullsFirst"))
@Deprecated("Use nullsFirst from kotlin.comparisons package.", ReplaceWith("nullsFirst<T>()", "kotlin.comparisons.nullsFirst"), level = DeprecationLevel.ERROR)
public fun <T: Comparable<T>> nullsFirst(): Comparator<T?> = nullsFirst(naturalOrder())
/**
* Extends the given [comparator] of non-nullable values to a comparator of nullable values
* considering `null` value greater than any other value.
*/
@Deprecated("Use nullsLast from kotlin.comparisons package.", ReplaceWith("nullsLast(comparator)", "kotlin.comparisons.nullsLast"))
@Deprecated("Use nullsLast from kotlin.comparisons package.", ReplaceWith("nullsLast(comparator)", "kotlin.comparisons.nullsLast"), level = DeprecationLevel.ERROR)
public fun <T: Any> nullsLast(comparator: Comparator<in T>): Comparator<T?> {
return object: Comparator<T?> {
override fun compare(a: T?, b: T?): Int {
@@ -285,23 +286,23 @@ public fun <T: Any> nullsLast(comparator: Comparator<in T>): Comparator<T?> {
* Provides a comparator of nullable [Comparable] values
* considering `null` value greater than any other value.
*/
@Deprecated("Use nullsLast from kotlin.comparisons package.", ReplaceWith("nullsLast<T>()", "kotlin.comparisons.nullsLast"))
@Deprecated("Use nullsLast from kotlin.comparisons package.", ReplaceWith("nullsLast<T>()", "kotlin.comparisons.nullsLast"), level = DeprecationLevel.ERROR)
public fun <T: Comparable<T>> nullsLast(): Comparator<T?> = nullsLast(naturalOrder())
/**
* Returns a comparator that compares [Comparable] objects in natural order.
*/
@Deprecated("Use naturalOrder from kotlin.comparisons package.", ReplaceWith("naturalOrder<T>()", "kotlin.comparisons.naturalOrder"))
@Deprecated("Use naturalOrder from kotlin.comparisons package.", ReplaceWith("naturalOrder<T>()", "kotlin.comparisons.naturalOrder"), level = DeprecationLevel.ERROR)
public fun <T: Comparable<T>> naturalOrder(): Comparator<T> = NaturalOrderComparator as Comparator<T>
/**
* Returns a comparator that compares [Comparable] objects in reversed natural order.
*/
@Deprecated("Use reverseOrder from kotlin.comparisons package.", ReplaceWith("reverseOrder<T>()", "kotlin.comparisons.reverseOrder"))
@Deprecated("Use reverseOrder from kotlin.comparisons package.", ReplaceWith("reverseOrder<T>()", "kotlin.comparisons.reverseOrder"), level = DeprecationLevel.ERROR)
public fun <T: Comparable<T>> reverseOrder(): Comparator<T> = ReverseOrderComparator as Comparator<T>
/** Returns a comparator that imposes the reverse ordering of this comparator. */
@Deprecated("Use reversed from kotlin.comparisons package.", ReplaceWith("this.reversed()", "kotlin.comparisons.reversed"))
@Deprecated("Use reversed from kotlin.comparisons package.", ReplaceWith("this.reversed()", "kotlin.comparisons.reversed"), level = DeprecationLevel.ERROR)
public fun <T> Comparator<T>.reversed(): Comparator<T> = when (this) {
is ReversedComparator -> this.comparator
NaturalOrderComparator -> ReverseOrderComparator as Comparator<T>