kotlin.collections.java.util.concurrent.ConcurrentMap.getOrPut

getOrPut

inline fun <K, V> ConcurrentMap<K, V>.getOrPut(
    key: K, 
    defaultValue: () -> V
): V

Platform and version requirements: JVM

Concurrent getOrPut, that is safe for concurrent maps.

Returns the value for the given key. If the key is not found in the map, calls the defaultValue function, puts its result into the map under the given key and returns it.

This method guarantees not to put the value into the map if the key is already there, but the defaultValue function may be invoked even if the key is already in the map.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/java.util.concurrent.-concurrent-map/get-or-put.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部