Memory
expect class Memory
Represents a linear range of bytes. All operations are guarded by range-checks by default however at some platforms they could be disabled in release builds.
Instance of this class has no additional state except the bytes themselves.
Constructors
Memory(buffer: ByteBuffer) |
Properties
val buffer: ByteBuffer |
|
val size: Long Size of memory range in bytes. |
|
val size32: Int Size of memory range in bytes represented as signed 32bit integer |
Functions
Copies bytes from this memory range from the specified offset and length to the destination at destinationOffset. Copying bytes from a memory to itself is allowed. |
|
Returns byte at index position. |
|
Returns memory’s subrange. On some platforms it could do range checks but it is not guaranteed to be safe. It also could lead to memory allocations on some platforms. |
|
Companion Object Properties
val Empty: Memory Represents an empty memory region |
Extension Functions
expect fun Memory.copyTo( expect fun Memory.copyTo( Copies bytes from this memory range from the specified offset and length to the destination at destinationOffset. fun Memory.copyTo(destination: ByteBuffer, offset: Int): Unit fun Memory.copyTo( Copies bytes from this memory range from the specified offset to the destination buffer. |
|
Fill memory range starting at the specified offset with value repeated count times. |
|
Read byte at the specified index. |
|
fun Memory.loadByteArray( Copies bytes from this memory range from the specified offset and count to the destination at destinationOffset. fun Memory.loadByteArray( Copies unsigned shorts integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
expect fun Memory.loadDoubleArray( expect fun Memory.loadDoubleArray( Copies floating point numbers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read short signed 64bit floating point number in the network byte order (Big Endian) |
|
expect fun Memory.loadFloatArray( expect fun Memory.loadFloatArray( Copies floating point numbers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read short signed 32bit floating point number in the network byte order (Big Endian) |
|
expect fun Memory.loadIntArray( expect fun Memory.loadIntArray( Copies regular integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read regular signed 32bit integer in the network byte order (Big Endian) |
|
expect fun Memory.loadLongArray( expect fun Memory.loadLongArray( Copies long integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read short signed 64bit integer in the network byte order (Big Endian) |
|
expect fun Memory.loadShortArray( expect fun Memory.loadShortArray( Copies shorts integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read short signed 16bit integer in the network byte order (Big Endian) |
|
fun Memory.loadUByteArray( fun Memory.loadUByteArray( Copies unsigned shorts integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
fun Memory.loadUIntArray( fun Memory.loadUIntArray( Copies unsigned integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read regular unsigned 32bit integer in the network byte order (Big Endian) |
|
fun Memory.loadULongArray( fun Memory.loadULongArray( Copies unsigned long integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read short signed 64bit integer in the network byte order (Big Endian) |
|
fun Memory.loadUShortArray( fun Memory.loadUShortArray( Copies unsigned shorts integers from this memory range from the specified offset and count to the destination at destinationOffset interpreting numbers in the network order (Big Endian). |
|
Read short unsigned 16bit integer in the network byte order (Big Endian) |
|
fun Memory.storeByteArray( fun Memory.storeByteArray( Copies unsigned shorts integers from the source array at sourceOffset to this memory at the specified offset. |
|
expect fun Memory.storeDoubleArray( expect fun Memory.storeDoubleArray( Copies floating point numbers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write short signed 64bit floating point number in the network byte order (Big Endian) |
|
expect fun Memory.storeFloatArray( expect fun Memory.storeFloatArray( Copies floating point numbers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write short signed 32bit floating point number in the network byte order (Big Endian) |
|
expect fun Memory.storeIntArray( expect fun Memory.storeIntArray( Copies regular integers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write regular signed 32bit integer in the network byte order (Big Endian) |
|
expect fun Memory.storeLongArray( expect fun Memory.storeLongArray( Copies long integers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write short signed 64bit integer in the network byte order (Big Endian) write short signed 64bit integer in the network byte order (Big Endian) |
|
expect fun Memory.storeShortArray( expect fun Memory.storeShortArray( Copies shorts integers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write short signed 16bit integer in the network byte order (Big Endian) |
|
fun Memory.storeUByteArray( fun Memory.storeUByteArray( Copies unsigned shorts integers from the source array at sourceOffset to this memory at the specified offset. |
|
fun Memory.storeUIntArray( fun Memory.storeUIntArray( Copies unsigned integers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write regular unsigned 32bit integer in the network byte order (Big Endian) |
|
fun Memory.storeULongArray( fun Memory.storeULongArray( Copies unsigned long integers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write short signed 64bit integer in the network byte order (Big Endian) |
|
fun Memory.storeUShortArray( fun Memory.storeUShortArray( Copies unsigned shorts integers from the source array at sourceOffset to this memory at the specified offset interpreting numbers in the network order (Big Endian). |
|
Write short unsigned 16bit integer in the network byte order (Big Endian) |
Companion Object Extension Functions
fun Memory.Companion.of( Create Memory view for the specified array range starting at offset and the specified bytes length. fun Memory.Companion.of(buffer: ByteBuffer): Memory Create Memory view for the specified buffer range starting at ByteBuffer.position and ending at ByteBuffer.limit. Changing the original buffer’s position/limit will not affect previously created Memory instances. |