Skip to content

Commit

Permalink
Buffer's buffers are stored in a ListBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
pityka committed Jan 26, 2024
1 parent b7a4ff3 commit ab7ae3e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions saddle-core/src/main/scala/org/saddle/Buffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
package org.saddle

import scala.reflect.ClassTag
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.{Buffer => SBuffer}
import scala.collection.mutable.ListBuffer

final class Buffer[@specialized V] private[saddle] (
private var arrays: ArrayBuffer[Array[V]],
private var arrays: SBuffer[Array[V]],
var length: Int
)(implicit
val ctV: ClassTag[V]
Expand Down Expand Up @@ -99,12 +100,13 @@ object Buffer {

val INIT_CAPACITY = startSize


def empty[@specialized(Int, Double, Boolean, Float) T: ClassTag]: Buffer[T] =
new Buffer(ArrayBuffer(new Array[T](startSize)), 0)
new Buffer(ListBuffer(new Array[T](startSize)), 0)

def empty[@specialized(Int, Double, Boolean, Float) T: ClassTag](
initSize: Int
): Buffer[T] =
new Buffer(ArrayBuffer(new Array[T](initSize)), 0)
new Buffer(ListBuffer(new Array[T](initSize)), 0)

}

0 comments on commit ab7ae3e

Please sign in to comment.