@@ -52,6 +52,18 @@ object opaques:
52
52
// but we can use `exists` instead, which is how `ArrayOps#contains` itself is implemented:
53
53
genericArrayOps(arr).exists(_ == elem)
54
54
55
+ /** Copy elements of this array to another array. */
56
+ extension [T , U >: T ](arr : IArray [T ]) def copyToArray (xs : Array [U ]): Int =
57
+ genericArrayOps(arr).copyToArray(xs)
58
+
59
+ /** Copy elements of this array to another array. */
60
+ extension [T , U >: T ](arr : IArray [T ]) def copyToArray (xs : Array [U ], start : Int ): Int =
61
+ genericArrayOps(arr).copyToArray(xs, start)
62
+
63
+ /** Copy elements of this array to another array. */
64
+ extension [T , U >: T ](arr : IArray [T ]) def copyToArray (xs : Array [U ], start : Int , len : Int ): Int =
65
+ genericArrayOps(arr).copyToArray(xs, start, len)
66
+
55
67
/** Counts the number of elements in this array which satisfy a predicate */
56
68
extension [T ](arr : IArray [T ]) def count (p : T => Boolean ): Int =
57
69
genericArrayOps(arr).count(p)
@@ -247,6 +259,10 @@ object opaques:
247
259
extension [T ](arr : IArray [T ]) def takeWhile (p : T => Boolean ): IArray [T ] =
248
260
genericArrayOps(arr).takeWhile(p)
249
261
262
+ /** Returns a mutable copy of this immutable array. */
263
+ extension [T ](arr : IArray [T ]) def toArray : Array [T ] =
264
+ arr.clone.asInstanceOf [Array [T ]]
265
+
250
266
/** Converts an array of pairs into an array of first elements and an array of second elements. */
251
267
extension [U : ClassTag , V : ClassTag ](arr : IArray [(U , V )]) def unzip : (IArray [U ], IArray [V ]) =
252
268
genericArrayOps(arr).unzip
0 commit comments