Hide toMap with keySelector

#KT-6657
This commit is contained in:
Ilya Gorbunov
2015-11-30 04:18:40 +03:00
parent ea60ab74a7
commit 0ffce06356
5 changed files with 41 additions and 41 deletions
+27 -27
View File
@@ -5842,53 +5842,53 @@ public fun ShortArray.toList(): List<Short> {
return this.toArrayList()
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <T, K> Array<out T>.toMap(selector: (T) -> K): Map<K, T> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> BooleanArray.toMap(selector: (Boolean) -> K): Map<K, Boolean> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> ByteArray.toMap(selector: (Byte) -> K): Map<K, Byte> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> CharArray.toMap(selector: (Char) -> K): Map<K, Char> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> DoubleArray.toMap(selector: (Double) -> K): Map<K, Double> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> FloatArray.toMap(selector: (Float) -> K): Map<K, Float> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> IntArray.toMap(selector: (Int) -> K): Map<K, Int> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> LongArray.toMap(selector: (Long) -> K): Map<K, Long> {
return toMapBy(selector)
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> ShortArray.toMap(selector: (Short) -> K): Map<K, Short> {
return toMapBy(selector)
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <T, K, V> Array<out T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
@@ -5901,7 +5901,7 @@ public inline fun <T, K, V> Array<out T>.toMap(selector: (T) -> K, transform: (T
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> BooleanArray.toMap(selector: (Boolean) -> K, transform: (Boolean) -> V): Map<K, V> {
@@ -5914,7 +5914,7 @@ public inline fun <K, V> BooleanArray.toMap(selector: (Boolean) -> K, transform:
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> ByteArray.toMap(selector: (Byte) -> K, transform: (Byte) -> V): Map<K, V> {
@@ -5927,7 +5927,7 @@ public inline fun <K, V> ByteArray.toMap(selector: (Byte) -> K, transform: (Byte
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> CharArray.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
@@ -5940,7 +5940,7 @@ public inline fun <K, V> CharArray.toMap(selector: (Char) -> K, transform: (Char
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> DoubleArray.toMap(selector: (Double) -> K, transform: (Double) -> V): Map<K, V> {
@@ -5953,7 +5953,7 @@ public inline fun <K, V> DoubleArray.toMap(selector: (Double) -> K, transform: (
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> FloatArray.toMap(selector: (Float) -> K, transform: (Float) -> V): Map<K, V> {
@@ -5966,7 +5966,7 @@ public inline fun <K, V> FloatArray.toMap(selector: (Float) -> K, transform: (Fl
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> IntArray.toMap(selector: (Int) -> K, transform: (Int) -> V): Map<K, V> {
@@ -5979,7 +5979,7 @@ public inline fun <K, V> IntArray.toMap(selector: (Int) -> K, transform: (Int) -
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> LongArray.toMap(selector: (Long) -> K, transform: (Long) -> V): Map<K, V> {
@@ -5992,7 +5992,7 @@ public inline fun <K, V> LongArray.toMap(selector: (Long) -> K, transform: (Long
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array.
* 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.
*/
public inline fun <K, V> ShortArray.toMap(selector: (Short) -> K, transform: (Short) -> V): Map<K, V> {
@@ -6005,7 +6005,7 @@ public inline fun <K, V> ShortArray.toMap(selector: (Short) -> K, transform: (Sh
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6019,7 +6019,7 @@ public inline fun <T, K> Array<out T>.toMapBy(selector: (T) -> K): Map<K, T> {
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6033,7 +6033,7 @@ public inline fun <K> BooleanArray.toMapBy(selector: (Boolean) -> K): Map<K, Boo
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6047,7 +6047,7 @@ public inline fun <K> ByteArray.toMapBy(selector: (Byte) -> K): Map<K, Byte> {
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6061,7 +6061,7 @@ public inline fun <K> CharArray.toMapBy(selector: (Char) -> K): Map<K, Char> {
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6075,7 +6075,7 @@ public inline fun <K> DoubleArray.toMapBy(selector: (Double) -> K): Map<K, Doubl
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6089,7 +6089,7 @@ public inline fun <K> FloatArray.toMapBy(selector: (Float) -> K): Map<K, Float>
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6103,7 +6103,7 @@ public inline fun <K> IntArray.toMapBy(selector: (Int) -> K): Map<K, Int> {
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -6117,7 +6117,7 @@ public inline fun <K> LongArray.toMapBy(selector: (Long) -> K): Map<K, Long> {
}
/**
* Returns Map containing the elements from the given array indexed by the key
* Returns a [Map] containing the elements from the given array indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -1064,13 +1064,13 @@ public fun <T> Iterable<T>.toList(): List<T> {
return this.toArrayList()
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <T, K> Iterable<T>.toMap(selector: (T) -> K): Map<K, T> {
return toMapBy(selector)
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given collection.
* 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.
*/
public inline fun <T, K, V> Iterable<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
@@ -1083,7 +1083,7 @@ public inline fun <T, K, V> Iterable<T>.toMap(selector: (T) -> K, transform: (T)
}
/**
* Returns Map containing the elements from the given collection indexed by the key
* Returns a [Map] containing the elements from the given collection indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
+3 -3
View File
@@ -522,13 +522,13 @@ public fun <T> Sequence<T>.toList(): List<T> {
return this.toArrayList()
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <T, K> Sequence<T>.toMap(selector: (T) -> K): Map<K, T> {
return toMapBy(selector)
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given sequence.
* 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.
*/
public inline fun <T, K, V> Sequence<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
@@ -540,7 +540,7 @@ public inline fun <T, K, V> Sequence<T>.toMap(selector: (T) -> K, transform: (T)
}
/**
* Returns Map containing the elements from the given sequence indexed by the key
* Returns a [Map] containing the elements from the given sequence indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
+5 -5
View File
@@ -805,7 +805,7 @@ public fun String.toList(): List<Char> {
return this.toArrayList()
}
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"))
@Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)"), level = DeprecationLevel.HIDDEN)
public inline fun <K> CharSequence.toMap(selector: (Char) -> K): Map<K, Char> {
return toMapBy(selector)
}
@@ -816,7 +816,7 @@ public inline fun <K> String.toMap(selector: (Char) -> K): Map<K, Char> {
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given char sequence.
* 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.
*/
public inline fun <K, V> CharSequence.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
@@ -829,7 +829,7 @@ public inline fun <K, V> CharSequence.toMap(selector: (Char) -> K, transform: (C
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given string.
* Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given string.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
@@ -843,7 +843,7 @@ public inline fun <K, V> String.toMap(selector: (Char) -> K, transform: (Char) -
}
/**
* Returns Map containing the characters from the given char sequence indexed by the key
* Returns a [Map] containing the characters from the given char sequence indexed by the key
* returned from [selector] function applied to each character.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -857,7 +857,7 @@ public inline fun <K> CharSequence.toMapBy(selector: (Char) -> K): Map<K, Char>
}
/**
* Returns Map containing the characters from the given string indexed by the key
* Returns a [Map] containing the characters from the given string indexed by the key
* returned from [selector] function applied to each character.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
@@ -124,7 +124,7 @@ fun snapshots(): List<GenericFunction> {
include(CharSequences, Strings)
typeParam("K")
returns("Map<K, T>")
deprecate(Deprecation("Use toMapBy instead.", replaceWith = "toMapBy(selector)"))
deprecate(Deprecation("Use toMapBy instead.", replaceWith = "toMapBy(selector)", level = DeprecationLevel.HIDDEN))
}
templates add f("toMapBy(selector: (T) -> K)") {
@@ -132,7 +132,7 @@ fun snapshots(): List<GenericFunction> {
typeParam("K")
doc { f ->
"""
Returns Map containing the ${f.element.pluralize()} from the given ${f.collection} indexed by the key
Returns a [Map] containing the ${f.element.pluralize()} from the given ${f.collection} indexed by the key
returned from [selector] function applied to each ${f.element}.
If any two ${f.element.pluralize()} would have the same key returned by [selector] the last one gets added to the map.
"""
@@ -192,7 +192,7 @@ fun snapshots(): List<GenericFunction> {
typeParam("V")
doc { f ->
"""
Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to ${f.element.pluralize()} of the given ${f.collection}.
Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to ${f.element.pluralize()} of the given ${f.collection}.
If any two ${f.element.pluralize()} would have the same key returned by [selector] the last one gets added to the map.
"""
}