forked from kscience/kmath
Implement copy for DataViewMemory
This commit is contained in:
parent
3f2520eecb
commit
548966f5bd
@ -11,16 +11,15 @@ class DataViewMemory(val view: DataView) : Memory {
|
|||||||
override fun view(offset: Int, length: Int): Memory {
|
override fun view(offset: Int, length: Int): Memory {
|
||||||
require(offset >= 0) { "offset shouldn't be negative: $offset" }
|
require(offset >= 0) { "offset shouldn't be negative: $offset" }
|
||||||
require(length >= 0) { "length shouldn't be negative: $length" }
|
require(length >= 0) { "length shouldn't be negative: $length" }
|
||||||
if (offset + length > size) {
|
|
||||||
|
if (offset + length > size)
|
||||||
throw IndexOutOfBoundsException("offset + length > size: $offset + $length > $size")
|
throw IndexOutOfBoundsException("offset + length > size: $offset + $length > $size")
|
||||||
}
|
|
||||||
return DataViewMemory(DataView(view.buffer, view.byteOffset + offset, length))
|
return DataViewMemory(DataView(view.buffer, view.byteOffset + offset, length))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun copy(): Memory {
|
override fun copy(): Memory = DataViewMemory(DataView(view.buffer.slice(0)))
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
private val reader = object : MemoryReader {
|
private val reader = object : MemoryReader {
|
||||||
override val memory: Memory get() = this@DataViewMemory
|
override val memory: Memory get() = this@DataViewMemory
|
||||||
|
Loading…
Reference in New Issue
Block a user