I\'ve searched for the use of @specialized
in the source code of the standard library of Scala 2.8.1. It looks like only a handful of traits and classes use this an
Partial answer to my own question: I can wrap an array in an IndexedSeq
like this:
import scala.collection.immutable.IndexedSeq
def arrayToIndexedSeq[@specialized(Int) T](array: Array[T]): IndexedSeq[T] = new IndexedSeq[T] {
def apply(idx: Int): T = array(idx)
def length: Int = array.length
}
(Ofcourse you could still modify the contents if you have access to the underlying array, but I would make sure that the array isn't passed to other parts of my program).