diff options
author | Erik Osheim <d_m@plastic-idolatry.com> | 2012-03-25 21:04:58 -0400 |
---|---|---|
committer | Erik Osheim <d_m@plastic-idolatry.com> | 2012-03-25 21:04:58 -0400 |
commit | 4b0d4571ecc8cfb1550c24a2cf11c8d0d535c36f (patch) | |
tree | 69a436f32290e81e09ca2bc3c3a1e4464dbf90f9 /src | |
parent | a532ba0600444b3564b6b015688ebc4cdf084ba6 (diff) | |
download | scala-4b0d4571ecc8cfb1550c24a2cf11c8d0d535c36f.tar.gz scala-4b0d4571ecc8cfb1550c24a2cf11c8d0d535c36f.tar.bz2 scala-4b0d4571ecc8cfb1550c24a2cf11c8d0d535c36f.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/mutable/FlatArray.scala | 11 |
1 files 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] = { |