kotlin.collections.associate

associate

inline fun <T, K, V> Iterable<T>.associate(
    transform: (T) -> Pair<K, V>
): Map<K, V>

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.

The returned map preserves the entry iteration order of the original collection.

inline fun <T, K, V> Array<out T>.associate(
    transform: (T) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> ByteArray.associate(
    transform: (Byte) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> ShortArray.associate(
    transform: (Short) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> IntArray.associate(
    transform: (Int) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> LongArray.associate(
    transform: (Long) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> FloatArray.associate(
    transform: (Float) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> DoubleArray.associate(
    transform: (Double) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> BooleanArray.associate(
    transform: (Boolean) -> Pair<K, V>
): Map<K, V>
inline fun <K, V> CharArray.associate(
    transform: (Char) -> Pair<K, V>
): Map<K, V>

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.

The returned map preserves the entry iteration order of the original array.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/associate.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部