File tree 1 file changed +15
-1
lines changed
compat/src/main/scala-2.11_2.12/scala/collection/compat/immutable 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ abstract class ArraySeq[+T] extends AbstractSeq[T] with IndexedSeq[T] {
58
58
/** Creates new builder for this collection ==> move to subclasses
59
59
*/
60
60
override protected [this ] def newBuilder : Builder [T , ArraySeq [T ]] =
61
- new WrappedArrayBuilder [T ](elemTag).mapResult(w => ArraySeq .unsafeWrapArray(w.array) )
61
+ ArraySeq .newBuilder [T ](elemTag)
62
62
63
63
}
64
64
@@ -69,6 +69,20 @@ object ArraySeq {
69
69
private val EmptyArraySeq = new ofRef[AnyRef ](new Array [AnyRef ](0 ))
70
70
def empty [T <: AnyRef ]: ArraySeq [T ] = EmptyArraySeq .asInstanceOf [ArraySeq [T ]]
71
71
72
+ def newBuilder [T ](implicit elemTag : ClassTag [T ]): Builder [T , ArraySeq [T ]] =
73
+ new WrappedArrayBuilder [T ](elemTag).mapResult(w => unsafeWrapArray(w.array))
74
+
75
+ def apply [T ](elems : T * )(implicit elemTag : ClassTag [T ]): ArraySeq [T ] = {
76
+ if (elems.isEmpty) empty[T ]
77
+ else {
78
+ val b = newBuilder[T ]
79
+ b ++= elems
80
+ b.result()
81
+ }
82
+ }
83
+
84
+ def unapplySeq [T ](seq : ArraySeq [T ]): Some [Seq [T ]] = Some (seq)
85
+
72
86
/**
73
87
* Wrap an existing `Array` into an `ArraySeq` of the proper primitive specialization type
74
88
* without copying.
You can’t perform that action at this time.
0 commit comments