Rename toMap and toMapBy to associate and associateBy
This commit is contained in:
@@ -5413,6 +5413,366 @@ public fun Array<out Short>.toShortArray(): ShortArray {
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Array<out T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> BooleanArray.associate(transform: (Boolean) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ByteArray.associate(transform: (Byte) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharArray.associate(transform: (Char) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> DoubleArray.associate(transform: (Double) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> FloatArray.associate(transform: (Float) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> IntArray.associate(transform: (Int) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> LongArray.associate(transform: (Long) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ShortArray.associate(transform: (Short) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K> Array<out T>.associateBy(keySelector: (T) -> K): Map<K, T> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> BooleanArray.associateBy(keySelector: (Boolean) -> K): Map<K, Boolean> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Boolean>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> ByteArray.associateBy(keySelector: (Byte) -> K): Map<K, Byte> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Byte>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> CharArray.associateBy(keySelector: (Char) -> K): Map<K, Char> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Char>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> DoubleArray.associateBy(keySelector: (Double) -> K): Map<K, Double> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Double>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> FloatArray.associateBy(keySelector: (Float) -> K): Map<K, Float> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Float>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> IntArray.associateBy(keySelector: (Int) -> K): Map<K, Int> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Int>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> LongArray.associateBy(keySelector: (Long) -> K): Map<K, Long> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Long>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given array indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> ShortArray.associateBy(keySelector: (Short) -> K): Map<K, Short> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Short>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Array<out T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> BooleanArray.associateBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ByteArray.associateBy(keySelector: (Byte) -> K, valueTransform: (Byte) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharArray.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> DoubleArray.associateBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> FloatArray.associateBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> IntArray.associateBy(keySelector: (Int) -> K, valueTransform: (Int) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> LongArray.associateBy(keySelector: (Long) -> K, valueTransform: (Long) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ShortArray.associateBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an [ArrayList] of all elements.
|
||||
*/
|
||||
@@ -5712,450 +6072,225 @@ 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <T, K, V> Array<out T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> BooleanArray.toMap(selector: (Boolean) -> K, transform: (Boolean) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> ByteArray.toMap(selector: (Byte) -> K, transform: (Byte) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> CharArray.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> DoubleArray.toMap(selector: (Double) -> K, transform: (Double) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> FloatArray.toMap(selector: (Float) -> K, transform: (Float) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> IntArray.toMap(selector: (Int) -> K, transform: (Int) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> LongArray.toMap(selector: (Long) -> K, transform: (Long) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> ShortArray.toMap(selector: (Short) -> K, transform: (Short) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <T, K, V> Array<out T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> BooleanArray.toMap(transform: (Boolean) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> ByteArray.toMap(transform: (Byte) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> CharArray.toMap(transform: (Char) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> DoubleArray.toMap(transform: (Double) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> FloatArray.toMap(transform: (Float) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> IntArray.toMap(transform: (Int) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> LongArray.toMap(transform: (Long) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> ShortArray.toMap(transform: (Short) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <T, K> Array<out T>.toMapBy(selector: (T) -> K): Map<K, T> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> BooleanArray.toMapBy(selector: (Boolean) -> K): Map<K, Boolean> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Boolean>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> ByteArray.toMapBy(selector: (Byte) -> K): Map<K, Byte> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Byte>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> CharArray.toMapBy(selector: (Char) -> K): Map<K, Char> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Char>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> DoubleArray.toMapBy(selector: (Double) -> K): Map<K, Double> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Double>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> FloatArray.toMapBy(selector: (Float) -> K): Map<K, Float> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Float>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> IntArray.toMapBy(selector: (Int) -> K): Map<K, Int> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Int>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> LongArray.toMapBy(selector: (Long) -> K): Map<K, Long> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Long>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> ShortArray.toMapBy(selector: (Short) -> K): Map<K, Short> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, Short>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)"))
|
||||
public inline fun <T, K, V> Array<out T>.toMapBy(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> BooleanArray.toMapBy(selector: (Boolean) -> K, transform: (Boolean) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> ByteArray.toMapBy(selector: (Byte) -> K, transform: (Byte) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> CharArray.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> DoubleArray.toMapBy(selector: (Double) -> K, transform: (Double) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> FloatArray.toMapBy(selector: (Float) -> K, transform: (Float) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> IntArray.toMapBy(selector: (Int) -> K, transform: (Int) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> LongArray.toMapBy(selector: (Long) -> K, transform: (Long) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, 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)"))
|
||||
public inline fun <K, V> ShortArray.toMapBy(selector: (Short) -> K, transform: (Short) -> V): Map<K, V> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -913,6 +913,46 @@ public fun Collection<Short>.toShortArray(): ShortArray {
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given collection.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given collection indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K, T> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given collection.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an [ArrayList] of all elements.
|
||||
*/
|
||||
@@ -957,50 +997,25 @@ 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <T, K, V> Iterable<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given collection.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <T, K, V> Iterable<T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <T, K> Iterable<T>.toMapBy(selector: (T) -> K): Map<K, T> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)"))
|
||||
public inline fun <T, K, V> Iterable<T>.toMapBy(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -422,6 +422,43 @@ public fun <T> Sequence<T>.sortedWith(comparator: Comparator<in T>): Sequence<T>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given sequence.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Sequence<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val result = LinkedHashMap<K, V>()
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the elements from the given sequence indexed by the key
|
||||
* returned from [keySelector] function applied to each element.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K> Sequence<T>.associateBy(keySelector: (T) -> K): Map<K, T> {
|
||||
val result = LinkedHashMap<K, T>()
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given sequence.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Sequence<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {
|
||||
val result = LinkedHashMap<K, V>()
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an [ArrayList] of all elements.
|
||||
*/
|
||||
@@ -457,47 +494,25 @@ 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <T, K, V> Sequence<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given sequence.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <T, K, V> Sequence<T>.toMap(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val result = LinkedHashMap<K, V>()
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <T, K> Sequence<T>.toMapBy(selector: (T) -> K): Map<K, T> {
|
||||
val result = LinkedHashMap<K, T>()
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)"))
|
||||
public inline fun <T, K, V> Sequence<T>.toMapBy(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
|
||||
val result = LinkedHashMap<K, V>()
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -491,6 +491,46 @@ public fun String.reversed(): String {
|
||||
return StringBuilder(this).reverse().toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to characters of the given char sequence.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharSequence.associate(transform: (Char) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the characters from the given char sequence indexed by the key
|
||||
* returned from [keySelector] function applied to each character.
|
||||
* If any two characters would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> CharSequence.associateBy(keySelector: (Char) -> K): Map<K, Char> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, Char>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to characters of the given char sequence.
|
||||
* If any two characters would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharSequence.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, V> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an [ArrayList] of all characters.
|
||||
*/
|
||||
@@ -526,50 +566,25 @@ 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 toMapBy instead.", ReplaceWith("toMapBy(selector, transform)"))
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"))
|
||||
public inline fun <K, V> CharSequence.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
|
||||
return toMapBy(selector, transform)
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to characters of the given char sequence.
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"))
|
||||
@kotlin.jvm.JvmName("toMapOfPairs")
|
||||
public inline fun <K, V> CharSequence.toMap(transform: (Char) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result += transform(element)
|
||||
}
|
||||
return result
|
||||
return associate(transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"))
|
||||
public inline fun <K> CharSequence.toMapBy(selector: (Char) -> K): Map<K, Char> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, Char>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
return result
|
||||
return associateBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)"))
|
||||
public inline fun <K, V> CharSequence.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
}
|
||||
return result
|
||||
return associateBy(selector, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -161,7 +161,7 @@ public enum class CharCategory(public val value: Int, public val code: String) {
|
||||
|
||||
|
||||
public companion object {
|
||||
private val categoryMap by lazy { CharCategory.values().toMapBy { it.value } }
|
||||
private val categoryMap by lazy { CharCategory.values().associateBy { it.value } }
|
||||
|
||||
public fun valueOf(category: Int): CharCategory = categoryMap[category] ?: throw IllegalArgumentException("Category #$category is not defined.")
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public enum class CharDirectionality(public val value: Int) {
|
||||
|
||||
|
||||
public companion object {
|
||||
private val directionalityMap by lazy { CharDirectionality.values().toMapBy { it.value } }
|
||||
private val directionalityMap by lazy { CharDirectionality.values().associateBy { it.value } }
|
||||
|
||||
public fun valueOf(directionality: Int): CharDirectionality = directionalityMap[directionality] ?: throw IllegalArgumentException("Directionality #$directionality is not defined.")
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class MapJVMTest {
|
||||
}
|
||||
|
||||
@test fun iterateAndRemove() {
|
||||
val map = (1..5).toMapBy({ it }, { 'a' + it }).toLinkedMap()
|
||||
val map = (1..5).associateBy({ it }, { 'a' + it }).toLinkedMap()
|
||||
val iterator = map.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().key % 2 == 0)
|
||||
|
||||
@@ -172,7 +172,7 @@ class MapTest {
|
||||
}
|
||||
|
||||
@test fun createWithSelector() {
|
||||
val map = listOf("a", "bb", "ccc").toMapBy { it.length }
|
||||
val map = listOf("a", "bb", "ccc").associateBy { it.length }
|
||||
assertEquals(3, map.size)
|
||||
assertEquals("a", map.get(1))
|
||||
assertEquals("bb", map.get(2))
|
||||
@@ -180,14 +180,14 @@ class MapTest {
|
||||
}
|
||||
|
||||
@test fun createWithSelectorAndOverwrite() {
|
||||
val map = listOf("aa", "bb", "ccc").toMapBy { it.length }
|
||||
val map = listOf("aa", "bb", "ccc").associateBy { it.length }
|
||||
assertEquals(2, map.size)
|
||||
assertEquals("bb", map.get(2))
|
||||
assertEquals("ccc", map.get(3))
|
||||
}
|
||||
|
||||
@test fun createWithSelectorForKeyAndValue() {
|
||||
val map = listOf("a", "bb", "ccc").toMapBy({ it.length }, { it.toUpperCase() })
|
||||
val map = listOf("a", "bb", "ccc").associateBy({ it.length }, { it.toUpperCase() })
|
||||
assertEquals(3, map.size)
|
||||
assertEquals("A", map[1])
|
||||
assertEquals("BB", map[2])
|
||||
@@ -195,7 +195,7 @@ class MapTest {
|
||||
}
|
||||
|
||||
@test fun createWithPairSelector() {
|
||||
val map = listOf("a", "bb", "ccc").toMap { it.length to it.toUpperCase() }
|
||||
val map = listOf("a", "bb", "ccc").associate { it.length to it.toUpperCase() }
|
||||
assertEquals(3, map.size)
|
||||
assertEquals("A", map[1])
|
||||
assertEquals("BB", map[2])
|
||||
|
||||
@@ -170,11 +170,11 @@ fun mapDefinitions(repository: Repository, definitions: Iterable<InterfaceDefini
|
||||
definitions.filter { "NoInterfaceObject" !in it.extendedAttributes.map { it.call } }.map { generateTrait(repository, it) }
|
||||
|
||||
fun generateUnions(ifaces: List<GenerateTraitOrClass>, typedefs: Iterable<TypedefDefinition>): GenerateUnionTypes {
|
||||
val declaredTypes = ifaces.toMapBy { it.name }
|
||||
val declaredTypes = ifaces.associateBy { it.name }
|
||||
|
||||
val anonymousUnionTypes = collectUnionTypes(declaredTypes)
|
||||
val anonymousUnionTypeTraits = generateUnionTypeTraits(anonymousUnionTypes)
|
||||
val anonymousUnionsMap = anonymousUnionTypeTraits.toMapBy { it.name }
|
||||
val anonymousUnionsMap = anonymousUnionTypeTraits.associateBy { it.name }
|
||||
|
||||
val typedefsToBeGenerated = typedefs.filter { it.types is UnionType }
|
||||
.map { NamedValue(it.name, it.types as UnionType) }
|
||||
|
||||
@@ -227,7 +227,7 @@ private fun Pair<String, String>.betterName() = if (((0..9).map { it.toString()
|
||||
fun <K, V> List<Pair<K, V>>.toMultiMap(): Map<K, List<V>> = groupBy { it.first }.mapValues { it.value.map { it.second } }
|
||||
|
||||
fun Appendable.render(namespace: String, ifaces: List<GenerateTraitOrClass>, unions : GenerateUnionTypes) {
|
||||
val declaredTypes = ifaces.toMapBy { it.name }
|
||||
val declaredTypes = ifaces.associateBy { it.name }
|
||||
|
||||
val allTypes = declaredTypes + unions.anonymousUnionsMap + unions.typedefsMarkersMap
|
||||
declaredTypes.values.filter { it.namespace == namespace }.forEach {
|
||||
|
||||
@@ -111,6 +111,15 @@ fun snapshots(): List<GenericFunction> {
|
||||
typeParam("V")
|
||||
returns("Map<K, V>")
|
||||
annotations("""@kotlin.jvm.JvmName("toMapOfPairs")""")
|
||||
deprecate(Deprecation("Use associate instead.", replaceWith = "associate(transform)"))
|
||||
}
|
||||
|
||||
templates add f("associate(transform: (T) -> Pair<K, V>)") {
|
||||
inline(true)
|
||||
include(CharSequences)
|
||||
typeParam("K")
|
||||
typeParam("V")
|
||||
returns("Map<K, V>")
|
||||
doc { f ->
|
||||
"""
|
||||
Returns a [Map] containing key-value pairs provided by [transform] function applied to ${f.element}s of the given ${f.collection}.
|
||||
@@ -159,13 +168,21 @@ fun snapshots(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("toMapBy(selector: (T) -> K)") {
|
||||
inline(true)
|
||||
typeParam("K")
|
||||
returns("Map<K, T>")
|
||||
include(CharSequences)
|
||||
deprecate(Deprecation("Use associateBy instead.", replaceWith = "associateBy(selector)"))
|
||||
}
|
||||
|
||||
templates add f("associateBy(keySelector: (T) -> K)") {
|
||||
inline(true)
|
||||
typeParam("K")
|
||||
doc { f ->
|
||||
"""
|
||||
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.
|
||||
returned from [keySelector] function applied to each ${f.element}.
|
||||
If any two ${f.element.pluralize()} would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
"""
|
||||
}
|
||||
returns("Map<K, T>")
|
||||
@@ -180,7 +197,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -189,7 +206,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
"""
|
||||
val result = LinkedHashMap<K, T>()
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -199,7 +216,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -209,7 +226,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
result.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -228,17 +245,26 @@ fun snapshots(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
returns("Map<K, V>")
|
||||
deprecate(Deprecation("Use toMapBy instead.", "toMapBy(selector, transform)"))
|
||||
deprecate(Deprecation("Use associateBy instead.", "associateBy(selector, transform)"))
|
||||
}
|
||||
|
||||
templates add f("toMapBy(selector: (T) -> K, transform: (T) -> V)") {
|
||||
inline(true)
|
||||
typeParam("K")
|
||||
typeParam("V")
|
||||
include(CharSequences)
|
||||
returns("Map<K, V>")
|
||||
deprecate(Deprecation("Use associateBy instead.", replaceWith = "associateBy(selector, transform)"))
|
||||
}
|
||||
|
||||
templates add f("associateBy(keySelector: (T) -> K, valueTransform: (T) -> V)") {
|
||||
inline(true)
|
||||
typeParam("K")
|
||||
typeParam("V")
|
||||
doc { f ->
|
||||
"""
|
||||
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.
|
||||
Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to ${f.element.pluralize()} of the given ${f.collection}.
|
||||
If any two ${f.element.pluralize()} would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
"""
|
||||
}
|
||||
returns("Map<K, V>")
|
||||
@@ -253,7 +279,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
val capacity = (collectionSizeOrDefault(10)/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -262,7 +288,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
"""
|
||||
val result = LinkedHashMap<K, V>()
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -272,7 +298,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
val capacity = (length/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
"""
|
||||
@@ -282,7 +308,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
val capacity = (size/.75f) + 1
|
||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||
for (element in this) {
|
||||
result.put(selector(element), transform(element))
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return result
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user