diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index 261aa1e24..865ad2f6d 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -1881,15 +1881,6 @@ public final class space/kscience/kmath/structures/MutableBuffer$Companion { public final fun short-1yRgbGw (ILkotlin/jvm/functions/Function1;)[S } -public final class space/kscience/kmath/structures/MutableBufferFromGenerator : space/kscience/kmath/structures/MutableBuffer { - public fun (ILkotlin/jvm/functions/Function1;)V - public fun copy ()Lspace/kscience/kmath/structures/MutableBuffer; - public fun get (I)Ljava/lang/Object; - public fun getSize ()I - public fun iterator ()Ljava/util/Iterator; - public fun set (ILjava/lang/Object;)V -} - public final class space/kscience/kmath/structures/MutableListBuffer : space/kscience/kmath/structures/MutableBuffer { public static final synthetic fun box-impl (Ljava/util/List;)Lspace/kscience/kmath/structures/MutableListBuffer; public static fun constructor-impl (ILkotlin/jvm/functions/Function1;)Ljava/util/List; diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt index d987d8cf4..28ae07a3c 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt @@ -8,7 +8,7 @@ package space.kscience.kmath.nd import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.VirtualBuffer -import space.kscience.kmath.structures.MutableBufferFromGenerator +import space.kscience.kmath.structures.MutableListBuffer import kotlin.jvm.JvmInline import kotlin.reflect.KClass @@ -81,13 +81,13 @@ public interface MutableStructure2D : Structure2D, MutableStructureND { * The buffer of rows of this structure. It gets elements from the structure dynamically. */ override val rows: List> - get() = List(rowNum) { i -> MutableBuffer1DWrapper(MutableBufferFromGenerator(colNum) { j -> get(i, j) })} + get() = List(rowNum) { i -> MutableBuffer1DWrapper(MutableListBuffer(colNum) { j -> get(i, j) })} /** * The buffer of columns of this structure. It gets elements from the structure dynamically. */ override val columns: List> - get() = List(colNum) { j -> MutableBuffer1DWrapper(MutableBufferFromGenerator(rowNum) { i -> get(i, j) }) } + get() = List(colNum) { j -> MutableBuffer1DWrapper(MutableListBuffer(rowNum) { i -> get(i, j) }) } } /** diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt index 19018ffb5..be5dfb359 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt @@ -292,24 +292,6 @@ public class VirtualBuffer(override val size: Int, private val generator: (In override operator fun iterator(): Iterator = (0 until size).asSequence().map(generator).iterator() } -public class MutableBufferFromGenerator(override val size: Int, private val generator: (Int) -> T) : MutableBuffer { - - private val bufferHolder: MutableListBuffer = (0 until size).map(generator).toMutableList().asMutableBuffer() - - override operator fun get(index: Int): T { - if (index < 0 || index >= size) throw IndexOutOfBoundsException("Expected index from 0 to ${size - 1}, but found $index") - return bufferHolder[index] - } - - override operator fun iterator(): Iterator = bufferHolder.iterator() - - override fun set(index: Int, value: T) { - bufferHolder[index] = value - } - - override fun copy(): MutableBuffer = bufferHolder.copy() -} - /** * Convert this buffer to read-only buffer. */