java - Using Generic Primitive Arrays in Scala -


this question has answer here:

i asked this question whether possible parameterize type of primitive array in java. (basically, have array want either double[] or float[] based on argument. i'm using arrays of primitives rather arrays of wrapper classes (double[], float[]) because they're more memory-and-time efficient, when dealing big vector operations. answer, appears, no, can't in java.

so, new question is: can in scala? understand primitives kind of more hidden, , boxed on operations... if possible parameterize arrays being of double or float, , compiler implement them primitives, how tell if they're being unboxed, or otherwise implemented less efficiently if go "find: double, replace: float" in source code?

does work you?

object specialisedarray {   def apply[@specialized(float, double) t: classtag](size: int) = new array[t](size) } 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -