in src/main/scala/com/spotify/bdrc/scala/JavaPrimitives.scala [42:58]
def jDoubleListToSeq(xs: JList[JDouble]): Seq[Double] = xs.asScala.asInstanceOf[Seq[Double]]
/**
* Array[Double] is more efficient since it's implemented as a Java primitive array. Arrays are
* also mutable so it'scheaper to pre-allocate and mutate elements. Java iterator and while loop
* are faster than `xs.asScala.asInstanceOf[Seq[Double]].toArray`.
*/
def jDoubleListToArray(xs: JList[JDouble]): Array[Double] = {
val a = new Array[Double](xs.size())
var i = 0
val iterator = xs.iterator()
while (iterator.hasNext) {
a(i) = iterator.next()
i += 1
}
a
}