MutablePointer

interface MutablePointer<T> : Pointer<T> (source)

A mutable pointer points to a value in memory. It can be used to pass a value by reference. The advantage of a pointer is that it can be used to change the value of a variable in a function.

Since

0.1.0

Parameters

T

The type of the value the pointer points to

See also

Inheritors

Properties

Link copied to clipboard
abstract override var value: T

The value the pointer points to

Functions

Link copied to clipboard
open fun <A> chain(transform: (T) -> Pointer<A>): Pointer<A>

Chain the value of the pointer. Creates a new pointer which will get the value on access, transform it and return it. So if you change the value of the original pointer the value of the new pointer will change too. Is the same as transform but the transform functions parameter should return a value, this function parameter should return a pointer.

Link copied to clipboard
open fun <A> chainAllowNull(transform: (T) -> Pointer<A?>?): Pointer<A?>

Chain the value of the pointer. Creates a new pointer which will get the value on access, transform it and return it. So if you change the value of the original pointer the value of the new pointer will change too. Is the same as transform but the transform functions parameter should return a value, this function parameter should return a pointer. This function allows null values.

Link copied to clipboard
fun <T> Pointer<T?>.notNull(msg: String? = null): Pointer<T>

Make sure that the value of the pointer is not null

Link copied to clipboard
fun <T> Pointer<T>.register(register: PointerRegister<T>): Int

Register the pointer to the given register

Link copied to clipboard
open fun <A> transform(transform: (T) -> A): Pointer<A>

Transform the value of the pointer. Creates a new pointer which will get the value on access, transform it and return it. So if you change the value of the original pointer the value of the new pointer will change too.

Link copied to clipboard

Close the pointer (unregister it from all registers)

fun <T> Pointer<T>.unregister(register: PointerRegister<T>)

Unregister the pointer from the given register