Delete wrap function

This commit is contained in:
Iaroslav Postovalov 2021-01-05 22:55:27 +07:00
parent 08afa59dcc
commit 51f2ec68fb
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7
4 changed files with 0 additions and 29 deletions

View File

@ -157,9 +157,3 @@ public inline fun Memory.write(block: MemoryWriter.() -> Unit) {
* Allocates the most effective platform-specific memory.
*/
public expect fun Memory.Companion.allocate(length: Int): Memory
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
* and could be mutated independently from the resulting [Memory].
*/
public expect fun Memory.Companion.wrap(array: ByteArray): Memory

View File

@ -7,7 +7,6 @@ package space.kscience.kmath.memory
import org.khronos.webgl.ArrayBuffer
import org.khronos.webgl.DataView
import org.khronos.webgl.Int8Array
private class DataViewMemory(val view: DataView) : Memory {
override val size: Int get() = view.byteLength
@ -91,12 +90,3 @@ public actual fun Memory.Companion.allocate(length: Int): Memory {
val buffer = ArrayBuffer(length)
return DataViewMemory(DataView(buffer, 0, length))
}
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
* and could be mutated independently from the resulting [Memory].
*/
public actual fun Memory.Companion.wrap(array: ByteArray): Memory {
val int8Array = array.unsafeCast<Int8Array>()
return DataViewMemory(DataView(int8Array.buffer, int8Array.byteOffset, int8Array.length))
}

View File

@ -102,13 +102,6 @@ internal class ByteBufferMemory(
public actual fun Memory.Companion.allocate(length: Int): Memory =
ByteBufferMemory(checkNotNull(ByteBuffer.allocate(length).order(ByteOrder.LITTLE_ENDIAN)))
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
* and could be mutated independently from the resulting [Memory].
*/
public actual fun Memory.Companion.wrap(array: ByteArray): Memory =
ByteBufferMemory(checkNotNull(ByteBuffer.wrap(array)))
/**
* Wraps this [ByteBuffer] to [Memory] object.
*

View File

@ -83,12 +83,6 @@ internal class NativeMemory(
override fun writer(): MemoryWriter = writer
}
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
* and could be mutated independently from the resulting [Memory].
*/
public actual fun Memory.Companion.wrap(array: ByteArray): Memory = NativeMemory(array)
/**
* Allocates the most effective platform-specific memory.
*/