Package-level declarations

Primitive weak data structures and their default (platform-specific) implementation.

Types

Link copied to clipboard
annotation class ExperimentalWeakApi
Link copied to clipboard
interface WeakMap<in K, V>

A weak map is a map in which elements can be garbage-collected at any moment.

Link copied to clipboard
interface WeakRef<out T>

A weak reference holds a reference to another object, without preventing that object from being garbage-collected.

Functions

Link copied to clipboard

Interprets a Java reference into a Kotlin WeakRef.

Link copied to clipboard
inline fun <K, V> WeakMap<K, V>.getOrDefault(key: K, defaultValue: V): V

Attempts to find the value associated with key, returning defaultValue if none is found.

Link copied to clipboard
inline fun <K, V> WeakMap<K, V>.getOrElse(key: K, defaultValue: () -> V): V

Attempts to find the value associated with key, returning the result of defaultValue if none is found.

Link copied to clipboard
inline fun <K, V> WeakMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V

Attempts to find the value associated with key.

Link copied to clipboard
inline operator fun <V> WeakMap<String, V>.getValue(thisRef: Any?, property: KProperty<*>): V?

Allows to use a weak map for data-oriented usage.

Link copied to clipboard
fun <K, V> WeakMap<K, V>.remove(key: K, value: V)

Removes the association of key to value from this map.

Link copied to clipboard

Removes the specified keys from this map.

fun <K, V> WeakMap<K, V>.removeAll(from: Map<out K, V>)

Removes the specified associations from this map.

Link copied to clipboard
fun <K, V> WeakMap<K, in V>.setAll(from: Map<out K, V>)

Sets all the values from the provided map into the current one.

Link copied to clipboard
inline operator fun <V> WeakMap<String, V>.setValue(thisRef: Any?, property: KProperty<*>, value: V)

Allows to use a weak map for data-oriented usage.

Link copied to clipboard
expect fun <T> SoftRef(value: T): WeakRef<T>

Instantiates a soft reference: a reference to a value that doesn't stop the garbage collector from collecting it.

actual fun <T> SoftRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a JS WeakRef.

actual fun <T> SoftRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a JVM SoftReference.

actual fun <T> SoftRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a native WeakReference.

actual fun <T> SoftRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a JS WeakRef.

Link copied to clipboard
expect fun <K, V> WeakMap(): WeakMap<K, V>

Instantiates a new, empty WeakMap.

expect fun <K, V> WeakMap(values: Map<K, V>): WeakMap<K, V>

Instantiates a new WeakMap by copying values.

actual fun <K, V> WeakMap(): WeakMap<K, V>

Instantiates a new, empty WeakMap.

actual fun <K, V> WeakMap(values: Map<K, V>): WeakMap<K, V>

Instantiates a new WeakMap by copying values.

actual fun <K, V> WeakMap(): WeakMap<K, V>

Instantiates a new, empty WeakMap.

actual fun <K, V> WeakMap(values: Map<K, V>): WeakMap<K, V>

Instantiates a new WeakMap by copying values.

actual fun <K, V> WeakMap(): WeakMap<K, V>

Instantiates a new, empty WeakMap.

actual fun <K, V> WeakMap(values: Map<K, V>): WeakMap<K, V>

Instantiates a new WeakMap by copying values.

actual fun <K, V> WeakMap(): WeakMap<K, V>

Instantiates a new, empty WeakMap.

actual fun <K, V> WeakMap(values: Map<K, V>): WeakMap<K, V>

Instantiates a new WeakMap by copying values.

Link copied to clipboard
expect fun <T> WeakRef(value: T): WeakRef<T>

Instantiates a weak reference: a reference to a value that doesn't stop the garbage collector from collecting it.

actual fun <T> WeakRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a JS WeakRef.

actual fun <T> WeakRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a JVM WeakReference.

actual fun <T> WeakRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a native WeakReference.

actual fun <T> WeakRef(value: T): WeakRef<T>

Implementation of WeakRef backed by a JS WeakRef.