|
1 | 1 | package scala
|
2 | 2 | import reflect.ClassTag
|
3 | 3 |
|
4 |
| -import scala.collection._ |
| 4 | +import scala.collection.{LazyZip2, SeqView, Searching, Stepper, StepperShape} |
| 5 | +import scala.collection.immutable.ArraySeq |
5 | 6 | import scala.collection.mutable.IArrayBuilder
|
6 | 7 |
|
7 | 8 | opaque type IArray[+T] = Array[_ <: T]
|
@@ -276,8 +277,8 @@ object IArray:
|
276 | 277 | def startsWith[U >: T](that: IterableOnce[U], offset: Int): Boolean = genericArrayOps(arr).startsWith(that, offset)
|
277 | 278 | def endsWith[U >: T](that: IArray[U]): Boolean = genericArrayOps(arr).endsWith(that)
|
278 | 279 | def endsWith[U >: T](that: Iterable[U]): Boolean = genericArrayOps(arr).endsWith(that)
|
279 |
| - def groupBy[K](f: T => K): immutable.Map[K, IArray[T]] = genericArrayOps(arr).groupBy(f) |
280 |
| - def groupMap[K, U: ClassTag](key: T => K)(f: T => U): immutable.Map[K, IArray[U]] = genericArrayOps(arr).groupMap(key)(f) |
| 280 | + def groupBy[K](f: T => K): Map[K, IArray[T]] = genericArrayOps(arr).groupBy(f) |
| 281 | + def groupMap[K, U: ClassTag](key: T => K)(f: T => U): Map[K, IArray[U]] = genericArrayOps(arr).groupMap(key)(f) |
281 | 282 | def grouped(size: Int): Iterator[IArray[T]] = genericArrayOps(arr).grouped(size)
|
282 | 283 | def inits: Iterator[IArray[T]] = genericArrayOps(arr).inits
|
283 | 284 | def intersect[U >: T](that: IArray[U]): IArray[T] = genericArrayOps(arr).intersect(that)
|
@@ -326,53 +327,53 @@ object IArray:
|
326 | 327 | def +:(arr: IArray[U]): IArray[U] = genericArrayOps(arr).prepended(x)
|
327 | 328 |
|
328 | 329 | /** Conversion from IArray to immutable.ArraySeq */
|
329 |
| - implicit def genericWrapArray[T](arr: IArray[T]): immutable.ArraySeq[T] = |
330 |
| - if arr eq null then null else immutable.ArraySeq.unsafeWrapArray(arr) |
| 330 | + implicit def genericWrapArray[T](arr: IArray[T]): ArraySeq[T] = |
| 331 | + if arr eq null then null else ArraySeq.unsafeWrapArray(arr) |
331 | 332 |
|
332 | 333 | /** Conversion from IArray to immutable.ArraySeq */
|
333 |
| - implicit def wrapRefArray[T <: AnyRef](arr: IArray[T]): immutable.ArraySeq.ofRef[T] = |
| 334 | + implicit def wrapRefArray[T <: AnyRef](arr: IArray[T]): ArraySeq.ofRef[T] = |
334 | 335 | // Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef]
|
335 | 336 | // is as good as another for all T <: AnyRef. Instead of creating 100,000,000
|
336 | 337 | // unique ones by way of this implicit, let's share one.
|
337 | 338 | if (arr eq null) null
|
338 |
| - else if (arr.length == 0) immutable.ArraySeq.empty[AnyRef].asInstanceOf[immutable.ArraySeq.ofRef[T]] |
339 |
| - else immutable.ArraySeq.ofRef(arr.asInstanceOf[Array[T]]) |
| 339 | + else if (arr.length == 0) ArraySeq.empty[AnyRef].asInstanceOf[ArraySeq.ofRef[T]] |
| 340 | + else ArraySeq.ofRef(arr.asInstanceOf[Array[T]]) |
340 | 341 |
|
341 | 342 | /** Conversion from IArray to immutable.ArraySeq */
|
342 |
| - implicit def wrapIntArray(arr: IArray[Int]): immutable.ArraySeq.ofInt = |
343 |
| - if (arr ne null) new immutable.ArraySeq.ofInt(arr.asInstanceOf[Array[Int]]) else null |
| 343 | + implicit def wrapIntArray(arr: IArray[Int]): ArraySeq.ofInt = |
| 344 | + if (arr ne null) new ArraySeq.ofInt(arr.asInstanceOf[Array[Int]]) else null |
344 | 345 |
|
345 | 346 | /** Conversion from IArray to immutable.ArraySeq */
|
346 |
| - implicit def wrapDoubleIArray(arr: IArray[Double]): immutable.ArraySeq.ofDouble = |
347 |
| - if (arr ne null) new immutable.ArraySeq.ofDouble(arr.asInstanceOf[Array[Double]]) else null |
| 347 | + implicit def wrapDoubleIArray(arr: IArray[Double]): ArraySeq.ofDouble = |
| 348 | + if (arr ne null) new ArraySeq.ofDouble(arr.asInstanceOf[Array[Double]]) else null |
348 | 349 |
|
349 | 350 | /** Conversion from IArray to immutable.ArraySeq */
|
350 |
| - implicit def wrapLongIArray(arr: IArray[Long]): immutable.ArraySeq.ofLong = |
351 |
| - if (arr ne null) new immutable.ArraySeq.ofLong(arr.asInstanceOf[Array[Long]]) else null |
| 351 | + implicit def wrapLongIArray(arr: IArray[Long]): ArraySeq.ofLong = |
| 352 | + if (arr ne null) new ArraySeq.ofLong(arr.asInstanceOf[Array[Long]]) else null |
352 | 353 |
|
353 | 354 | /** Conversion from IArray to immutable.ArraySeq */
|
354 |
| - implicit def wrapFloatIArray(arr: IArray[Float]): immutable.ArraySeq.ofFloat = |
355 |
| - if (arr ne null) new immutable.ArraySeq.ofFloat(arr.asInstanceOf[Array[Float]]) else null |
| 355 | + implicit def wrapFloatIArray(arr: IArray[Float]): ArraySeq.ofFloat = |
| 356 | + if (arr ne null) new ArraySeq.ofFloat(arr.asInstanceOf[Array[Float]]) else null |
356 | 357 |
|
357 | 358 | /** Conversion from IArray to immutable.ArraySeq */
|
358 |
| - implicit def wrapCharIArray(arr: IArray[Char]): immutable.ArraySeq.ofChar = |
359 |
| - if (arr ne null) new immutable.ArraySeq.ofChar(arr.asInstanceOf[Array[Char]]) else null |
| 359 | + implicit def wrapCharIArray(arr: IArray[Char]): ArraySeq.ofChar = |
| 360 | + if (arr ne null) new ArraySeq.ofChar(arr.asInstanceOf[Array[Char]]) else null |
360 | 361 |
|
361 | 362 | /** Conversion from IArray to immutable.ArraySeq */
|
362 |
| - implicit def wrapByteIArray(arr: IArray[Byte]): immutable.ArraySeq.ofByte = |
363 |
| - if (arr ne null) new immutable.ArraySeq.ofByte(arr.asInstanceOf[Array[Byte]]) else null |
| 363 | + implicit def wrapByteIArray(arr: IArray[Byte]): ArraySeq.ofByte = |
| 364 | + if (arr ne null) new ArraySeq.ofByte(arr.asInstanceOf[Array[Byte]]) else null |
364 | 365 |
|
365 | 366 | /** Conversion from IArray to immutable.ArraySeq */
|
366 |
| - implicit def wrapShortIArray(arr: IArray[Short]): immutable.ArraySeq.ofShort = |
367 |
| - if (arr ne null) new immutable.ArraySeq.ofShort(arr.asInstanceOf[Array[Short]]) else null |
| 367 | + implicit def wrapShortIArray(arr: IArray[Short]): ArraySeq.ofShort = |
| 368 | + if (arr ne null) new ArraySeq.ofShort(arr.asInstanceOf[Array[Short]]) else null |
368 | 369 |
|
369 | 370 | /** Conversion from IArray to immutable.ArraySeq */
|
370 |
| - implicit def wrapBooleanIArray(arr: IArray[Boolean]): immutable.ArraySeq.ofBoolean = |
371 |
| - if (arr ne null) new immutable.ArraySeq.ofBoolean(arr.asInstanceOf[Array[Boolean]]) else null |
| 371 | + implicit def wrapBooleanIArray(arr: IArray[Boolean]): ArraySeq.ofBoolean = |
| 372 | + if (arr ne null) new ArraySeq.ofBoolean(arr.asInstanceOf[Array[Boolean]]) else null |
372 | 373 |
|
373 | 374 | /** Conversion from IArray to immutable.ArraySeq */
|
374 |
| - implicit def wrapUnitIArray(arr: IArray[Unit]): immutable.ArraySeq.ofUnit = |
375 |
| - if (arr ne null) new immutable.ArraySeq.ofUnit(arr.asInstanceOf[Array[Unit]]) else null |
| 375 | + implicit def wrapUnitIArray(arr: IArray[Unit]): ArraySeq.ofUnit = |
| 376 | + if (arr ne null) new ArraySeq.ofUnit(arr.asInstanceOf[Array[Unit]]) else null |
376 | 377 |
|
377 | 378 | /** Convert an array into an immutable array without copying, the original array
|
378 | 379 | * must _not_ be mutated after this or the guaranteed immutablity of IArray will
|
@@ -451,7 +452,7 @@ object IArray:
|
451 | 452 | // `Array.concat` should arguably take in a `Seq[Array[_ <: T]]`,
|
452 | 453 | // but since it currently takes a `Seq[Array[T]]` we have to perform a cast,
|
453 | 454 | // knowing tacitly that `concat` is not going to do the wrong thing.
|
454 |
| - Array.concat[T](xss.asInstanceOf[immutable.Seq[Array[T]]]: _*) |
| 455 | + Array.concat[T](xss.asInstanceOf[Seq[Array[T]]]: _*) |
455 | 456 |
|
456 | 457 | /** Returns an immutable array that contains the results of some element computation a number
|
457 | 458 | * of times. Each element is determined by a separate computation.
|
|
0 commit comments