@@ -16,19 +16,19 @@ import java.util.Arrays
16
16
*
17
17
* Supports efficient indexed access and has a small memory footprint.
18
18
*
19
- * @define Coll `ImmutableArray `
19
+ * @define Coll `ArraySeq `
20
20
* @define coll wrapped array
21
21
* @define orderDependent
22
22
* @define orderDependentFold
23
23
* @define mayNotTerminateInf
24
24
* @define willNotTerminateInf
25
25
*/
26
- abstract class ImmutableArray [+ T ]
26
+ abstract class ArraySeq [+ T ]
27
27
extends AbstractSeq [T ]
28
28
with IndexedSeq [T ]
29
29
{
30
30
31
- override protected [this ] def thisCollection : ImmutableArray [T ] = this
31
+ override protected [this ] def thisCollection : ArraySeq [T ] = this
32
32
33
33
/** The tag of the element type */
34
34
protected [this ] def elemTag : ClassTag [T ]
@@ -45,31 +45,31 @@ abstract class ImmutableArray[+T]
45
45
private def elementClass : Class [_] =
46
46
unsafeArray.getClass.getComponentType
47
47
48
- override def stringPrefix = " ImmutableArray "
48
+ override def stringPrefix = " ArraySeq "
49
49
50
50
/** 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()
52
52
53
53
/** Creates new builder for this collection ==> move to subclasses
54
54
*/
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))
57
57
58
58
}
59
59
60
- /** A companion object used to create instances of `ImmutableArray `.
60
+ /** A companion object used to create instances of `ArraySeq `.
61
61
*/
62
- object ImmutableArray {
62
+ object ArraySeq {
63
63
// 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 ]]
66
66
67
67
// 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
69
69
// contract all empty ones must be equal, so discriminating based on the reference
70
70
// equality of an empty array should not come up) but we may as well be
71
71
// 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 {
73
73
case null => null
74
74
case x : Array [AnyRef ] => new ofRef[AnyRef ](x)
75
75
case x : Array [Int ] => new ofInt(x)
@@ -81,17 +81,17 @@ object ImmutableArray {
81
81
case x : Array [Short ] => new ofShort(x)
82
82
case x : Array [Boolean ] => new ofBoolean(x)
83
83
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 ]
92
92
}
93
93
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 {
95
95
lazy val elemTag = ClassTag [T ](unsafeArray.getClass.getComponentType)
96
96
def length : Int = unsafeArray.length
97
97
def apply (index : Int ): T = unsafeArray(index)
@@ -103,7 +103,7 @@ object ImmutableArray {
103
103
}
104
104
}
105
105
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 {
107
107
def elemTag = ClassTag .Byte
108
108
def length : Int = unsafeArray.length
109
109
def apply (index : Int ): Byte = unsafeArray(index)
@@ -115,7 +115,7 @@ object ImmutableArray {
115
115
}
116
116
}
117
117
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 {
119
119
def elemTag = ClassTag .Short
120
120
def length : Int = unsafeArray.length
121
121
def apply (index : Int ): Short = unsafeArray(index)
@@ -127,7 +127,7 @@ object ImmutableArray {
127
127
}
128
128
}
129
129
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 {
131
131
def elemTag = ClassTag .Char
132
132
def length : Int = unsafeArray.length
133
133
def apply (index : Int ): Char = unsafeArray(index)
@@ -139,7 +139,7 @@ object ImmutableArray {
139
139
}
140
140
}
141
141
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 {
143
143
def elemTag = ClassTag .Int
144
144
def length : Int = unsafeArray.length
145
145
def apply (index : Int ): Int = unsafeArray(index)
@@ -151,7 +151,7 @@ object ImmutableArray {
151
151
}
152
152
}
153
153
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 {
155
155
def elemTag = ClassTag .Long
156
156
def length : Int = unsafeArray.length
157
157
def apply (index : Int ): Long = unsafeArray(index)
@@ -163,7 +163,7 @@ object ImmutableArray {
163
163
}
164
164
}
165
165
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 {
167
167
def elemTag = ClassTag .Float
168
168
def length : Int = unsafeArray.length
169
169
def apply (index : Int ): Float = unsafeArray(index)
@@ -175,7 +175,7 @@ object ImmutableArray {
175
175
}
176
176
}
177
177
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 {
179
179
def elemTag = ClassTag .Double
180
180
def length : Int = unsafeArray.length
181
181
def apply (index : Int ): Double = unsafeArray(index)
@@ -187,7 +187,7 @@ object ImmutableArray {
187
187
}
188
188
}
189
189
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 {
191
191
def elemTag = ClassTag .Boolean
192
192
def length : Int = unsafeArray.length
193
193
def apply (index : Int ): Boolean = unsafeArray(index)
@@ -199,7 +199,7 @@ object ImmutableArray {
199
199
}
200
200
}
201
201
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 {
203
203
def elemTag = ClassTag .Unit
204
204
def length : Int = unsafeArray.length
205
205
def apply (index : Int ): Unit = unsafeArray(index)
0 commit comments