From 4b0d4571ecc8cfb1550c24a2cf11c8d0d535c36f Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Sun, 25 Mar 2012 21:04:58 -0400 Subject: Fix .empty and add .ofDim factory method. This commit removes the (unused and unnecessary) elems* parameter from the 'empty' method. It also adds 'ofDim' which allows the user to allocate a FlatArray of a given size without providing actual elements. This fixes SI-5609. --- src/library/scala/collection/mutable/FlatArray.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/library/scala/collection/mutable/FlatArray.scala b/src/library/scala/collection/mutable/FlatArray.scala index a7f994bf74..3e43b66ecf 100644 --- a/src/library/scala/collection/mutable/FlatArray.scala +++ b/src/library/scala/collection/mutable/FlatArray.scala @@ -60,8 +60,15 @@ extends AbstractSeq[T] */ object FlatArray { - def empty[Boxed, Unboxed](elems: Boxed*) - (implicit boxings: BoxingConversions[Boxed, Unboxed], elemManifest: ClassManifest[Unboxed]): FlatArray[Boxed] = apply() + def ofDim[Boxed, Unboxed](size:Int) + (implicit boxings: BoxingConversions[Boxed, Unboxed], + manifest: ClassManifest[Unboxed]): FlatArray[Boxed] = { + val elems = Array.ofDim[Unboxed](size) + new FlatArray.Impl(elems, boxings, manifest) + } + + def empty[Boxed, Unboxed](implicit boxings: BoxingConversions[Boxed, Unboxed], + elemManifest: ClassManifest[Unboxed]): FlatArray[Boxed] = apply() def apply[Boxed, Unboxed](elems: Boxed*) (implicit boxings: BoxingConversions[Boxed, Unboxed], elemManifest: ClassManifest[Unboxed]): FlatArray[Boxed] = { -- cgit v1.2.3