Introduce associateTo and associateByTo with the destination MutableMap to fill.
This commit is contained in:
@@ -5414,120 +5414,93 @@ public fun Array<out Short>.toShortArray(): ShortArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Map] containing key-value pairs provided by [transform] function applied to elements of the given array.
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5536,12 +5509,8 @@ public inline fun <K, V> ShortArray.associate(transform: (Short) -> Pair<K, V>):
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5550,12 +5519,8 @@ public inline fun <T, K> Array<out T>.associateBy(keySelector: (T) -> K): Map<K,
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Boolean>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5564,12 +5529,8 @@ public inline fun <K> BooleanArray.associateBy(keySelector: (Boolean) -> K): Map
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Byte>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5578,12 +5539,8 @@ public inline fun <K> ByteArray.associateBy(keySelector: (Byte) -> K): Map<K, By
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Char>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5592,12 +5549,8 @@ public inline fun <K> CharArray.associateBy(keySelector: (Char) -> K): Map<K, Ch
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Double>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5606,12 +5559,8 @@ public inline fun <K> DoubleArray.associateBy(keySelector: (Double) -> K): Map<K
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Float>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5620,12 +5569,8 @@ public inline fun <K> FloatArray.associateBy(keySelector: (Float) -> K): Map<K,
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Int>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5634,12 +5579,8 @@ public inline fun <K> IntArray.associateBy(keySelector: (Int) -> K): Map<K, Int>
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Long>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5648,12 +5589,8 @@ public inline fun <K> LongArray.associateBy(keySelector: (Long) -> K): Map<K, Lo
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Short>(capacity), keySelector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5661,12 +5598,8 @@ public inline fun <K> ShortArray.associateBy(keySelector: (Short) -> K): Map<K,
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5674,12 +5607,8 @@ public inline fun <T, K, V> Array<out T>.associateBy(keySelector: (T) -> K, valu
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5687,12 +5616,8 @@ public inline fun <K, V> BooleanArray.associateBy(keySelector: (Boolean) -> K, v
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5700,12 +5625,8 @@ public inline fun <K, V> ByteArray.associateBy(keySelector: (Byte) -> K, valueTr
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5713,12 +5634,8 @@ public inline fun <K, V> CharArray.associateBy(keySelector: (Char) -> K, valueTr
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5726,12 +5643,8 @@ public inline fun <K, V> DoubleArray.associateBy(keySelector: (Double) -> K, val
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5739,12 +5652,8 @@ public inline fun <K, V> FloatArray.associateBy(keySelector: (Float) -> K, value
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5752,12 +5661,8 @@ public inline fun <K, V> IntArray.associateBy(keySelector: (Int) -> K, valueTran
|
||||
* 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
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5765,12 +5670,350 @@ public inline fun <K, V> LongArray.associateBy(keySelector: (Long) -> K, valueTr
|
||||
* 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))
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* 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, M : MutableMap<in K, in T>> Array<out T>.associateByTo(destination: M, keySelector: (T) -> K): M {
|
||||
for (element in this) {
|
||||
result.put(keySelector(element), valueTransform(element))
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return result
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Boolean>> BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Byte>> ByteArray.associateByTo(destination: M, keySelector: (Byte) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Char>> CharArray.associateByTo(destination: M, keySelector: (Char) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Double>> DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Float>> FloatArray.associateByTo(destination: M, keySelector: (Float) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Int>> IntArray.associateByTo(destination: M, keySelector: (Int) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Long>> LongArray.associateByTo(destination: M, keySelector: (Long) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function applied to each element of the given array
|
||||
* and value is the element itself.
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, M : MutableMap<in K, in Short>> ShortArray.associateByTo(destination: M, keySelector: (Short) -> K): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> Array<out T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> ByteArray.associateByTo(destination: M, keySelector: (Byte) -> K, valueTransform: (Byte) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> CharArray.associateByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> FloatArray.associateByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> IntArray.associateByTo(destination: M, keySelector: (Int) -> K, valueTransform: (Int) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> LongArray.associateByTo(destination: M, keySelector: (Long) -> K, valueTransform: (Long) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs,
|
||||
* where key is provided by the [keySelector] function and
|
||||
* and value is provided by the [valueTransform] function 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, M : MutableMap<in K, in V>> ShortArray.associateByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M {
|
||||
for (element in this) {
|
||||
destination.put(keySelector(element), valueTransform(element))
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> Array<out T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> BooleanArray.associateTo(destination: M, transform: (Boolean) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> ByteArray.associateTo(destination: M, transform: (Byte) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> CharArray.associateTo(destination: M, transform: (Char) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> DoubleArray.associateTo(destination: M, transform: (Double) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> FloatArray.associateTo(destination: M, transform: (Float) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> IntArray.associateTo(destination: M, transform: (Int) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> LongArray.associateTo(destination: M, transform: (Long) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates and returns the [destination] mutable map with key-value pairs
|
||||
* provided by [transform] function applied to each element 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, M : MutableMap<in K, in V>> ShortArray.associateTo(destination: M, transform: (Short) -> Pair<K, V>): M {
|
||||
for (element in this) {
|
||||
destination += transform(element)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user