Skip to content

Commit b3111ba

Browse files
committed
Rename ImmutableArray -> ArraySeq
1 parent 659b966 commit b3111ba

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

src/main/scala-2.11_2.12/scala/collection/immutable/ImmutableArray.scala renamed to src/main/scala-2.11_2.12/scala/collection/immutable/ArraySeq.scala

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ import java.util.Arrays
1616
*
1717
* Supports efficient indexed access and has a small memory footprint.
1818
*
19-
* @define Coll `ImmutableArray`
19+
* @define Coll `ArraySeq`
2020
* @define coll wrapped array
2121
* @define orderDependent
2222
* @define orderDependentFold
2323
* @define mayNotTerminateInf
2424
* @define willNotTerminateInf
2525
*/
26-
abstract class ImmutableArray[+T]
26+
abstract class ArraySeq[+T]
2727
extends AbstractSeq[T]
2828
with IndexedSeq[T]
2929
{
3030

31-
override protected[this] def thisCollection: ImmutableArray[T] = this
31+
override protected[this] def thisCollection: ArraySeq[T] = this
3232

3333
/** The tag of the element type */
3434
protected[this] def elemTag: ClassTag[T]
@@ -45,31 +45,31 @@ abstract class ImmutableArray[+T]
4545
private def elementClass: Class[_] =
4646
unsafeArray.getClass.getComponentType
4747

48-
override def stringPrefix = "ImmutableArray"
48+
override def stringPrefix = "ArraySeq"
4949

5050
/** Clones this object, including the underlying Array. */
51-
override def clone(): ImmutableArray[T] = ImmutableArray unsafeWrapArray unsafeArray.clone()
51+
override def clone(): ArraySeq[T] = ArraySeq unsafeWrapArray unsafeArray.clone()
5252

5353
/** Creates new builder for this collection ==> move to subclasses
5454
*/
55-
override protected[this] def newBuilder: Builder[T, ImmutableArray[T]] =
56-
new WrappedArrayBuilder[T](elemTag).mapResult(w => ImmutableArray.unsafeWrapArray(w.array))
55+
override protected[this] def newBuilder: Builder[T, ArraySeq[T]] =
56+
new WrappedArrayBuilder[T](elemTag).mapResult(w => ArraySeq.unsafeWrapArray(w.array))
5757

5858
}
5959

60-
/** A companion object used to create instances of `ImmutableArray`.
60+
/** A companion object used to create instances of `ArraySeq`.
6161
*/
62-
object ImmutableArray {
62+
object ArraySeq {
6363
// This is reused for all calls to empty.
64-
private val EmptyImmutableArray = new ofRef[AnyRef](new Array[AnyRef](0))
65-
def empty[T <: AnyRef]: ImmutableArray[T] = EmptyImmutableArray.asInstanceOf[ImmutableArray[T]]
64+
private val EmptyArraySeq = new ofRef[AnyRef](new Array[AnyRef](0))
65+
def empty[T <: AnyRef]: ArraySeq[T] = EmptyArraySeq.asInstanceOf[ArraySeq[T]]
6666

6767
// If make is called explicitly we use whatever we're given, even if it's
68-
// empty. This may be unnecessary (if ImmutableArray is to honor the collections
68+
// empty. This may be unnecessary (if ArraySeq is to honor the collections
6969
// contract all empty ones must be equal, so discriminating based on the reference
7070
// equality of an empty array should not come up) but we may as well be
7171
// conservative since wrapRefArray contributes most of the unnecessary allocations.
72-
def unsafeWrapArray[T](x: AnyRef): ImmutableArray[T] = (x match {
72+
def unsafeWrapArray[T](x: AnyRef): ArraySeq[T] = (x match {
7373
case null => null
7474
case x: Array[AnyRef] => new ofRef[AnyRef](x)
7575
case x: Array[Int] => new ofInt(x)
@@ -81,17 +81,17 @@ object ImmutableArray {
8181
case x: Array[Short] => new ofShort(x)
8282
case x: Array[Boolean] => new ofBoolean(x)
8383
case x: Array[Unit] => new ofUnit(x)
84-
}).asInstanceOf[ImmutableArray[T]]
85-
86-
implicit def canBuildFrom[T](implicit m: ClassTag[T]): CanBuildFrom[ImmutableArray[_], T, ImmutableArray[T]] =
87-
new CanBuildFrom[ImmutableArray[_], T, ImmutableArray[T]] {
88-
def apply(from: ImmutableArray[_]): Builder[T, ImmutableArray[T]] =
89-
ArrayBuilder.make[T]()(m) mapResult ImmutableArray.unsafeWrapArray[T]
90-
def apply: Builder[T, ImmutableArray[T]] =
91-
ArrayBuilder.make[T]()(m) mapResult ImmutableArray.unsafeWrapArray[T]
84+
}).asInstanceOf[ArraySeq[T]]
85+
86+
implicit def canBuildFrom[T](implicit m: ClassTag[T]): CanBuildFrom[ArraySeq[_], T, ArraySeq[T]] =
87+
new CanBuildFrom[ArraySeq[_], T, ArraySeq[T]] {
88+
def apply(from: ArraySeq[_]): Builder[T, ArraySeq[T]] =
89+
ArrayBuilder.make[T]()(m) mapResult ArraySeq.unsafeWrapArray[T]
90+
def apply: Builder[T, ArraySeq[T]] =
91+
ArrayBuilder.make[T]()(m) mapResult ArraySeq.unsafeWrapArray[T]
9292
}
9393

94-
final class ofRef[T <: AnyRef](val unsafeArray: Array[T]) extends ImmutableArray[T] with Serializable {
94+
final class ofRef[T <: AnyRef](val unsafeArray: Array[T]) extends ArraySeq[T] with Serializable {
9595
lazy val elemTag = ClassTag[T](unsafeArray.getClass.getComponentType)
9696
def length: Int = unsafeArray.length
9797
def apply(index: Int): T = unsafeArray(index)
@@ -103,7 +103,7 @@ object ImmutableArray {
103103
}
104104
}
105105

106-
final class ofByte(val unsafeArray: Array[Byte]) extends ImmutableArray[Byte] with Serializable {
106+
final class ofByte(val unsafeArray: Array[Byte]) extends ArraySeq[Byte] with Serializable {
107107
def elemTag = ClassTag.Byte
108108
def length: Int = unsafeArray.length
109109
def apply(index: Int): Byte = unsafeArray(index)
@@ -115,7 +115,7 @@ object ImmutableArray {
115115
}
116116
}
117117

118-
final class ofShort(val unsafeArray: Array[Short]) extends ImmutableArray[Short] with Serializable {
118+
final class ofShort(val unsafeArray: Array[Short]) extends ArraySeq[Short] with Serializable {
119119
def elemTag = ClassTag.Short
120120
def length: Int = unsafeArray.length
121121
def apply(index: Int): Short = unsafeArray(index)
@@ -127,7 +127,7 @@ object ImmutableArray {
127127
}
128128
}
129129

130-
final class ofChar(val unsafeArray: Array[Char]) extends ImmutableArray[Char] with Serializable {
130+
final class ofChar(val unsafeArray: Array[Char]) extends ArraySeq[Char] with Serializable {
131131
def elemTag = ClassTag.Char
132132
def length: Int = unsafeArray.length
133133
def apply(index: Int): Char = unsafeArray(index)
@@ -139,7 +139,7 @@ object ImmutableArray {
139139
}
140140
}
141141

142-
final class ofInt(val unsafeArray: Array[Int]) extends ImmutableArray[Int] with Serializable {
142+
final class ofInt(val unsafeArray: Array[Int]) extends ArraySeq[Int] with Serializable {
143143
def elemTag = ClassTag.Int
144144
def length: Int = unsafeArray.length
145145
def apply(index: Int): Int = unsafeArray(index)
@@ -151,7 +151,7 @@ object ImmutableArray {
151151
}
152152
}
153153

154-
final class ofLong(val unsafeArray: Array[Long]) extends ImmutableArray[Long] with Serializable {
154+
final class ofLong(val unsafeArray: Array[Long]) extends ArraySeq[Long] with Serializable {
155155
def elemTag = ClassTag.Long
156156
def length: Int = unsafeArray.length
157157
def apply(index: Int): Long = unsafeArray(index)
@@ -163,7 +163,7 @@ object ImmutableArray {
163163
}
164164
}
165165

166-
final class ofFloat(val unsafeArray: Array[Float]) extends ImmutableArray[Float] with Serializable {
166+
final class ofFloat(val unsafeArray: Array[Float]) extends ArraySeq[Float] with Serializable {
167167
def elemTag = ClassTag.Float
168168
def length: Int = unsafeArray.length
169169
def apply(index: Int): Float = unsafeArray(index)
@@ -175,7 +175,7 @@ object ImmutableArray {
175175
}
176176
}
177177

178-
final class ofDouble(val unsafeArray: Array[Double]) extends ImmutableArray[Double] with Serializable {
178+
final class ofDouble(val unsafeArray: Array[Double]) extends ArraySeq[Double] with Serializable {
179179
def elemTag = ClassTag.Double
180180
def length: Int = unsafeArray.length
181181
def apply(index: Int): Double = unsafeArray(index)
@@ -187,7 +187,7 @@ object ImmutableArray {
187187
}
188188
}
189189

190-
final class ofBoolean(val unsafeArray: Array[Boolean]) extends ImmutableArray[Boolean] with Serializable {
190+
final class ofBoolean(val unsafeArray: Array[Boolean]) extends ArraySeq[Boolean] with Serializable {
191191
def elemTag = ClassTag.Boolean
192192
def length: Int = unsafeArray.length
193193
def apply(index: Int): Boolean = unsafeArray(index)
@@ -199,7 +199,7 @@ object ImmutableArray {
199199
}
200200
}
201201

202-
final class ofUnit(val unsafeArray: Array[Unit]) extends ImmutableArray[Unit] with Serializable {
202+
final class ofUnit(val unsafeArray: Array[Unit]) extends ArraySeq[Unit] with Serializable {
203203
def elemTag = ClassTag.Unit
204204
def length: Int = unsafeArray.length
205205
def apply(index: Int): Unit = unsafeArray(index)

src/test/scala/test/scala/collection/ImmutableArrayTest.scala renamed to src/test/scala/test/scala/collection/ArraySeqTest.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package test.scala.collection
22

33
import org.junit.{Assert, Test}
44

5-
import scala.collection.immutable.ImmutableArray
5+
import scala.collection.immutable.ArraySeq
66

7-
// The unmodified ImmutableArrayTest from collection-strawman
8-
class ImmutableArrayTest {
7+
// The unmodified ArraySeqTest from collection-strawman
8+
class ArraySeqTest {
99
@Test
1010
def slice(): Unit = {
1111

12-
implicit def array2ImmutableArray[T](array: Array[T]): ImmutableArray[T] =
13-
ImmutableArray.unsafeWrapArray(array)
12+
implicit def array2ArraySeq[T](array: Array[T]): ArraySeq[T] =
13+
ArraySeq.unsafeWrapArray(array)
1414

1515
val booleanArray = Array(true, false, true, false)
1616
check(booleanArray, Array(true, false), Array(false, true))
@@ -44,17 +44,17 @@ class ImmutableArrayTest {
4444
Assert.assertEquals(unit1, unit2)
4545
// unitArray is actually an instance of Immutable[BoxedUnit], the check to which is actually checked slice
4646
// implementation of ofRef
47-
val unitArray: ImmutableArray[Unit] = Array(unit1, unit2, unit1, unit2)
47+
val unitArray: ArraySeq[Unit] = Array(unit1, unit2, unit1, unit2)
4848
check(unitArray, Array(unit1, unit1), Array(unit1, unit1))
4949
}
5050

51-
private def check[T](array: ImmutableArray[T], expectedSliceResult1: ImmutableArray[T], expectedSliceResult2: ImmutableArray[T]) {
51+
private def check[T](array: ArraySeq[T], expectedSliceResult1: ArraySeq[T], expectedSliceResult2: ArraySeq[T]) {
5252
Assert.assertEquals(array, array.slice(-1, 4))
5353
Assert.assertEquals(array, array.slice(0, 5))
5454
Assert.assertEquals(array, array.slice(-1, 5))
5555
Assert.assertEquals(expectedSliceResult1, array.slice(0, 2))
5656
Assert.assertEquals(expectedSliceResult2, array.slice(1, 3))
57-
Assert.assertEquals(ImmutableArray.empty[Nothing], array.slice(1, 1))
58-
Assert.assertEquals(ImmutableArray.empty[Nothing], array.slice(2, 1))
57+
Assert.assertEquals(ArraySeq.empty[Nothing], array.slice(1, 1))
58+
Assert.assertEquals(ArraySeq.empty[Nothing], array.slice(2, 1))
5959
}
6060
}

0 commit comments

Comments
 (0)