Skip to content

Commit d7299b6

Browse files
committed
WrappedArray -> ArraySeq
1 parent da376f7 commit d7299b6

File tree

7 files changed

+23
-27
lines changed

7 files changed

+23
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ as the collection can (in some cases) be built in parallel.
161161

162162
Because the wrappers are invoked based on the static type of the collection, there are also cases where parallelization
163163
is inefficient when interfacing with Java 8 Streams (e.g. when a collection is typed as `Seq[String]` so might have linear
164-
access like `List`, but actually is a `WrappedArray[String]` that can be efficiently parallelized) but can be efficient
164+
access like `List`, but actually is an `ArraySeq[String]` that can be efficiently parallelized) but can be efficient
165165
with Scala parallel collections. The `parStream` method is only available when the static type is known to be compatible
166166
with rapid parallel operation; `seqStream` can be parallelized by using `.parallel`, but may or may not be efficient.
167167

benchmark/src/main/scala/bench/CollectionSource.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ package object generate {
256256

257257
class MuqThings(val sizes: Array[Int]) extends AbstractThings[collection.mutable.Queue]("mutable.Queue") {}
258258

259-
class WraThings(val sizes: Array[Int]) extends AbstractThings[collection.mutable.WrappedArray]("mutable.WrappedArray") {}
259+
class AsqThings(val sizes: Array[Int]) extends AbstractThings[collection.mutable.ArraySeq]("mutable.ArraySeq") {}
260260

261261
class JixThings(val sizes: Array[Int]) extends AbstractThings[java.util.ArrayList]("java.util.ArrayList") {}
262262

@@ -279,7 +279,7 @@ package object generate {
279279
lazy val lhs = new LhsThings(sizes)
280280
lazy val prq = new PrqThings(sizes)
281281
lazy val muq = new MuqThings(sizes)
282-
lazy val wra = new WraThings(sizes)
282+
lazy val asq = new AsqThings(sizes)
283283
lazy val jix = new JixThings(sizes)
284284
lazy val jln = new JlnThings(sizes)
285285
}

benchmark/src/main/scala/bench/ParseJmhLog.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object ParseJmhLog {
2424
"stm" -> "collection.immutable.Stream",
2525
"trs" -> "collection.immutable.TreeSet",
2626
"vec" -> "collection.immutable.Vector",
27-
"wra" -> "collection.mutable.WrappedArray",
27+
"asq" -> "collection.mutable.ArraySeq",
2828
"jix" -> "java.util.ArrayList",
2929
"jln" -> "java.util.LinkedList"
3030
)

src/main/scala/scala/compat/java8/StreamConverters.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,19 @@ with converterImpl.Priority1AccumulatorConverters
195195
def parStream: LongStream = seqStream.parallel
196196
}
197197

198-
implicit final class EnrichDoubleWrappedArrayWithStream(private val a: collection.mutable.WrappedArray[Double])
198+
implicit final class EnrichDoubleArraySeqWithStream(private val a: collection.mutable.ArraySeq[Double])
199199
extends AnyVal with MakesSequentialStream[Double, DoubleStream] with MakesParallelStream[Double, DoubleStream] {
200200
def seqStream: DoubleStream = java.util.Arrays.stream(a.array)
201201
def parStream: DoubleStream = seqStream.parallel
202202
}
203203

204-
implicit final class EnrichIntWrappedArrayWithStream(private val a: collection.mutable.WrappedArray[Int])
204+
implicit final class EnrichIntArraySeqWithStream(private val a: collection.mutable.ArraySeq[Int])
205205
extends AnyVal with MakesSequentialStream[Int, IntStream] with MakesParallelStream[Int, IntStream] {
206206
def seqStream: IntStream = java.util.Arrays.stream(a.array)
207207
def parStream: IntStream = seqStream.parallel
208208
}
209209

210-
implicit final class EnrichLongWrappedArrayWithStream(private val a: collection.mutable.WrappedArray[Long])
210+
implicit final class EnrichLongArraySeqWithStream(private val a: collection.mutable.ArraySeq[Long])
211211
extends AnyVal with MakesSequentialStream[Long, LongStream] with MakesParallelStream[Long, LongStream] {
212212
def seqStream: LongStream = java.util.Arrays.stream(a.array)
213213
def parStream: LongStream = seqStream.parallel

src/main/scala/scala/compat/java8/converterImpl/StepConverters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait Priority1StepConverters extends Priority2StepConverters {
1616
implicit def richDefaultHashMapCanStep[K, V](underlying: collection.mutable.HashMap[K, V]) = new RichHashMapCanStep[K, V](underlying)
1717
implicit def richLinkedHashMapCanStep[K, V](underlying: collection.mutable.LinkedHashMap[K, V]) = new RichLinkedHashMapCanStep[K, V](underlying)
1818
implicit def richArrayCanStep[A](underlying: Array[A]) = new RichArrayCanStep[A](underlying)
19-
implicit def richWrappedArrayCanStep[A](underlying: collection.mutable.WrappedArray[A]) = new RichArrayCanStep[A](underlying.array)
19+
implicit def richArraySeqCanStep[A](underlying: collection.mutable.ArraySeq[A]) = new RichArrayCanStep[A](underlying.array)
2020
implicit def richHashSetCanStep[A](underlying: collection.mutable.HashSet[A]) = new RichHashSetCanStep[A](underlying)
2121
implicit def richIteratorCanStep[A](underlying: Iterator[A]) = new RichIteratorCanStep(underlying)
2222
implicit def richImmHashMapCanStep[K, V](underlying: collection.immutable.HashMap[K, V]) = new RichImmHashMapCanStep[K, V](underlying)

src/test/scala/scala/compat/java8/StepConvertersTest.scala

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class StepConvertersTest {
153153
Okay( cm.AnyRefMap[String,String]("fish" -> "salmon").keyStepper )
154154
Okay( cm.AnyRefMap[String,String]("fish" -> "salmon").valueStepper )
155155
good( cm.ArrayBuffer[String]("salmon").stepper )
156-
good( (Array("salmon"): cm.WrappedArray[String]).stepper )
156+
good( (Array("salmon"): cm.ArraySeq[String]).stepper )
157157
good( cm.ArraySeq[String]("salmon").stepper )
158158
_eh_( cm.ArrayStack[String]("salmon").stepper )
159159
Okay( (cm.ArrayBuffer[String]("salmon"): cm.Buffer[String]).stepper )
@@ -192,7 +192,6 @@ class StepConvertersTest {
192192
Okay( cm.WeakHashMap[String, String]("fish" -> "salmon").stepper )
193193
Okay( cm.WeakHashMap[String, String]("fish" -> "salmon").keyStepper )
194194
Okay( cm.WeakHashMap[String, String]("fish" -> "salmon").valueStepper )
195-
good( (Array("salmon"): cm.WrappedArray[String]).stepper )
196195

197196
// Java 6 converters section
198197

@@ -272,7 +271,7 @@ class StepConvertersTest {
272271
Okay( (cm.HashSet[Double](3.14159): cm.AbstractSet[Double]).stepper )
273272
Okay( cm.AnyRefMap[String,Double]("fish" -> 3.14159).valueStepper )
274273
good( cm.ArrayBuffer[Double](3.14159).stepper )
275-
good( (Array(3.14159): cm.WrappedArray[Double]).stepper )
274+
good( (Array(3.14159): cm.ArraySeq[Double]).stepper )
276275
good( cm.ArraySeq[Double](3.14159).stepper )
277276
_eh_( cm.ArrayStack[Double](3.14159).stepper )
278277
Okay( (cm.ArrayBuffer[Double](3.14159): cm.Buffer[Double]).stepper )
@@ -304,7 +303,6 @@ class StepConvertersTest {
304303
Okay( cm.UnrolledBuffer[Double](3.14159).stepper )
305304
Okay( cm.WeakHashMap[Double, Double](2.718281828 -> 3.14159).keyStepper )
306305
Okay( cm.WeakHashMap[Double, Double](2.718281828 -> 3.14159).valueStepper )
307-
good( (Array(3.14159): cm.WrappedArray[Double]).stepper )
308306

309307
// Java 6 converters section
310308

@@ -392,7 +390,7 @@ class StepConvertersTest {
392390
Okay( (cm.HashSet[Int](654321): cm.AbstractSet[Int]).stepper )
393391
Okay( cm.AnyRefMap[String, Int]("fish" -> 654321).valueStepper )
394392
good( cm.ArrayBuffer[Int](654321).stepper )
395-
good( (Array(654321): cm.WrappedArray[Int]).stepper )
393+
good( (Array(654321): cm.ArraySeq[Int]).stepper )
396394
good( cm.ArraySeq[Int](654321).stepper )
397395
_eh_( cm.ArrayStack[Int](654321).stepper )
398396
Okay( (cm.ArrayBuffer[Int](654321): cm.Buffer[Int]).stepper )
@@ -424,7 +422,6 @@ class StepConvertersTest {
424422
Okay( cm.UnrolledBuffer[Int](654321).stepper )
425423
Okay( cm.WeakHashMap[Int, Int](0xDEEDED -> 654321).keyStepper )
426424
Okay( cm.WeakHashMap[Int, Int](0xDEEDED -> 654321).valueStepper )
427-
good( (Array(654321): cm.WrappedArray[Int]).stepper )
428425

429426
// Java 6 converters section
430427

@@ -440,12 +437,12 @@ class StepConvertersTest {
440437
implicit val spec = SpecCheck(_.isInstanceOf[IntStepper], x => s"$x should be an IntStepper")
441438

442439
good( Array[Short](654321.toShort).stepper )
443-
good( (Array[Short](654321.toShort): cm.WrappedArray[Short]).stepper )
440+
good( (Array[Short](654321.toShort): cm.ArraySeq[Short]).stepper )
444441

445442
//TODO: None of these currently work because there are no native Stepper implementations:
446443

447444
//good( ci.NumericRange(123456.toShort, 123458.toShort, 1.toShort).stepper )
448-
//good( ((Array[Short](654321.toShort): cm.WrappedArray[Short]): cm.ArrayLike[Short, cm.WrappedArray[Short]]).stepper )
445+
//good( ((Array[Short](654321.toShort): cm.ArraySeq[Short]): cm.ArrayLike[Short, cm.ArraySeq[Short]]).stepper )
449446
//good( (Array[Short](654321.toShort): cm.ArrayOps[Short]).stepper )
450447
//good( cm.ResizableArray[Short](654321.toShort).stepper )
451448
}
@@ -526,7 +523,7 @@ class StepConvertersTest {
526523
Okay( (cm.HashSet[Long](0x123456789L): cm.AbstractSet[Long]).stepper )
527524
Okay( cm.AnyRefMap[String,Long]("fish" -> 0x123456789L).valueStepper )
528525
good( cm.ArrayBuffer[Long](0x123456789L).stepper )
529-
good( (Array(0x123456789L): cm.WrappedArray[Long]).stepper )
526+
good( (Array(0x123456789L): cm.ArraySeq[Long]).stepper )
530527
good( cm.ArraySeq[Long](0x123456789L).stepper )
531528
_eh_( cm.ArrayStack[Long](0x123456789L).stepper )
532529
Okay( (cm.ArrayBuffer[Long](0x123456789L): cm.Buffer[Long]).stepper )
@@ -559,7 +556,6 @@ class StepConvertersTest {
559556
Okay( cm.UnrolledBuffer[Long](0x123456789L).stepper )
560557
Okay( cm.WeakHashMap[Long, Long](1234567654321L -> 0x123456789L).keyStepper )
561558
Okay( cm.WeakHashMap[Long, Long](1234567654321L -> 0x123456789L).valueStepper )
562-
good( (Array(0x123456789L): cm.WrappedArray[Long]).stepper )
563559

564560
// Java 6 converters section
565561

src/test/scala/scala/compat/java8/StreamConvertersTest.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ class StreamConvertersTest {
111111
assert(newLongStream(1).boxed.unboxed.isInstanceOf[LongStream])
112112
}
113113

114-
import collection.mutable.{ ArrayBuffer, WrappedArray }
114+
import collection.mutable.{ ArrayBuffer, ArraySeq }
115115
def abufO(n: Int) = { val ab = new ArrayBuffer[String]; arrayO(n).foreach(ab += _); ab }
116116
def abufD(n: Int) = { val ab = new ArrayBuffer[Double]; arrayD(n).foreach(ab += _); ab }
117117
def abufI(n: Int) = { val ab = new ArrayBuffer[Int]; arrayI(n).foreach(ab += _); ab }
118118
def abufL(n: Int) = { val ab = new ArrayBuffer[Long]; arrayL(n).foreach(ab += _); ab }
119-
def wrapO(n: Int): WrappedArray[String] = arrayO(n)
120-
def wrapD(n: Int): WrappedArray[Double] = arrayD(n)
121-
def wrapI(n: Int): WrappedArray[Int] = arrayI(n)
122-
def wrapL(n: Int): WrappedArray[Long] = arrayL(n)
119+
def wrapO(n: Int): ArraySeq[String] = arrayO(n)
120+
def wrapD(n: Int): ArraySeq[Double] = arrayD(n)
121+
def wrapI(n: Int): ArraySeq[Int] = arrayI(n)
122+
def wrapL(n: Int): ArraySeq[Long] = arrayL(n)
123123
def vectO(n: Int) = arrayO(n).toVector
124124
def vectD(n: Int) = arrayD(n).toVector
125125
def vectI(n: Int) = arrayI(n).toVector
@@ -257,10 +257,10 @@ class StreamConvertersTest {
257257

258258
@Test
259259
def streamMaterialization(): Unit = {
260-
val coll = collection.mutable.WrappedArray.make[Int](Array(1,2,3))
261-
val streamize = implicitly[collection.mutable.WrappedArray[Int] => MakesSequentialStream[Int, IntStream]]
262-
assertTrue(streamize(coll).getClass.getName.contains("EnrichIntWrappedArrayWithStream"))
263-
val steppize = implicitly[collection.mutable.WrappedArray[Int] => MakesStepper[Int, Any]]
260+
val coll = collection.mutable.ArraySeq.make[Int](Array(1,2,3))
261+
val streamize = implicitly[collection.mutable.ArraySeq[Int] => MakesSequentialStream[Int, IntStream]]
262+
assertTrue(streamize(coll).getClass.getName.contains("EnrichIntArraySeqWithStream"))
263+
val steppize = implicitly[collection.mutable.ArraySeq[Int] => MakesStepper[Int, Any]]
264264
assertTrue(steppize(coll).getClass.getName.contains("RichArrayCanStep"))
265265
val stepper = steppize(coll).stepper
266266
assertTrue(stepper.getClass.getName.contains("StepsIntArray"))

0 commit comments

Comments
 (0)