getOrPut

inline fun <V> SparseArray<V>.getOrPut(key: Int, defaultValue: () -> V): V

Gets value with specific key. If the value is not present, calls defaultValue to obtain a non-null value which is placed into the array, then returned.

This method is not thread-safe.