@@ -52,6 +52,18 @@ object opaques:
5252 // but we can use `exists` instead, which is how `ArrayOps#contains` itself is implemented:
5353 genericArrayOps(arr).exists(_ == elem)
5454
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+
5567 /** Counts the number of elements in this array which satisfy a predicate */
5668 extension [T ](arr : IArray [T ]) def count (p : T => Boolean ): Int =
5769 genericArrayOps(arr).count(p)
@@ -247,6 +259,10 @@ object opaques:
247259 extension [T ](arr : IArray [T ]) def takeWhile (p : T => Boolean ): IArray [T ] =
248260 genericArrayOps(arr).takeWhile(p)
249261
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+
250266 /** Converts an array of pairs into an array of first elements and an array of second elements. */
251267 extension [U : ClassTag , V : ClassTag ](arr : IArray [(U , V )]) def unzip : (IArray [U ], IArray [V ]) =
252268 genericArrayOps(arr).unzip
0 commit comments