Package space.kscience.kmath.memory

Types

Link copied to clipboard
interface Memory

Represents a display of certain memory structure.

Link copied to clipboard
interface MemoryReader

The interface to read primitive types in this memory.

Link copied to clipboard
interface MemorySpec<T : Any>

A specification to read or write custom objects with fixed size in bytes.

Link copied to clipboard
interface MemoryWriter

The interface to write primitive types into this memory.

Functions

Link copied to clipboard
expect fun Memory.Companion.allocate(length: Int): Memory

Allocates the most effective platform-specific memory.

actual fun Memory.Companion.allocate(length: Int): Memory

Allocates memory based on a DataView.

actual fun Memory.Companion.allocate(length: Int): Memory

Allocates memory based on a ByteBuffer.

actual fun Memory.Companion.allocate(length: Int): Memory

Allocates the most effective platform-specific memory.

Link copied to clipboard
fun ByteBuffer.asMemory(startOffset: Int = 0, size: Int = limit()): Memory

Wraps this ByteBuffer to Memory object.

Link copied to clipboard
inline fun <R> Memory.read(block: MemoryReader.() -> R): R

Uses the memory for read then releases the reader.

fun <T : Any> MemoryReader.read(spec: MemorySpec<T>, offset: Int): T

Reads the object with spec starting from offset.

Link copied to clipboard
inline fun <T : Any> MemoryReader.readArray(spec: MemorySpec<T>, offset: Int, size: Int): Array<T>

Reads array of size objects mapped by spec at certain offset.

Link copied to clipboard
inline fun <R> Path.readAsMemory(position: Long = 0, size: Long = Files.size(this), block: Memory.() -> R): R

Uses direct memory-mapped buffer from file to read something and close it afterwards.

Link copied to clipboard
expect fun Memory.Companion.wrap(array: ByteArray): Memory

Wraps a Memory around existing ByteArray. This operation is unsafe since the array is not copied and could be mutated independently of the resulting Memory.

actual fun Memory.Companion.wrap(array: ByteArray): Memory

Wraps a Memory around existing ByteArray. This operation is unsafe since the array is not copied and could be mutated independently of the resulting Memory.

actual fun Memory.Companion.wrap(array: ByteArray): Memory

Wraps a Memory around existing ByteArray. This operation is unsafe since the array is not copied and could be mutated independently of the resulting Memory.

actual fun Memory.Companion.wrap(array: ByteArray): Memory

Wraps a Memory around existing ByteArray. This operation is unsafe since the array is not copied and could be mutated independently of the resulting Memory.

Link copied to clipboard
inline fun Memory.write(block: MemoryWriter.() -> Unit)

Uses the memory for write then releases the writer.

fun <T : Any> MemoryWriter.write(spec: MemorySpec<T>, offset: Int, value: T)

Writes the object value with spec starting from offset.

Link copied to clipboard
fun <T : Any> MemoryWriter.writeArray(spec: MemorySpec<T>, offset: Int, array: Array<T>)

Writes array of objects mapped by spec at certain offset.