@@ -58,6 +58,15 @@ private[immutable] abstract class Node[T <: Node[T]] {
58
58
result
59
59
}
60
60
61
+ protected final def removeAnyElement (as : Array [Any ], ix : Int ): Array [Any ] = {
62
+ if (ix < 0 ) throw new ArrayIndexOutOfBoundsException
63
+ if (ix > as.length - 1 ) throw new ArrayIndexOutOfBoundsException
64
+ val result = new Array [Any ](as.length - 1 )
65
+ arraycopy(as, 0 , result, 0 , ix)
66
+ arraycopy(as, ix + 1 , result, ix, as.length - ix - 1 )
67
+ result
68
+ }
69
+
61
70
protected final def insertElement (as : Array [Int ], ix : Int , elem : Int ): Array [Int ] = {
62
71
if (ix < 0 ) throw new ArrayIndexOutOfBoundsException
63
72
if (ix > as.length) throw new ArrayIndexOutOfBoundsException
@@ -67,6 +76,15 @@ private[immutable] abstract class Node[T <: Node[T]] {
67
76
arraycopy(as, ix, result, ix + 1 , as.length - ix)
68
77
result
69
78
}
79
+ protected final def insertAnyElement (as : Array [Any ], ix : Int , elem : Int ): Array [Any ] = {
80
+ if (ix < 0 ) throw new ArrayIndexOutOfBoundsException
81
+ if (ix > as.length) throw new ArrayIndexOutOfBoundsException
82
+ val result = new Array [Any ](as.length + 1 )
83
+ arraycopy(as, 0 , result, 0 , ix)
84
+ result(ix) = elem
85
+ arraycopy(as, ix, result, ix + 1 , as.length - ix)
86
+ result
87
+ }
70
88
}
71
89
72
90
/**
0 commit comments