Index: runtime/lib/growable_array.dart |
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart |
index e1a858364b035e1c726ecd26c9da234cfeb3f1be..bdfe19cfe88e3f51d1c12419d221bdba3a93d396 100644 |
--- a/runtime/lib/growable_array.dart |
+++ b/runtime/lib/growable_array.dart |
@@ -8,6 +8,19 @@ class _GrowableObjectArray<T> implements List<T> { |
"GrowableObjectArray can only be allocated by the VM"); |
} |
+ void insertAt(int index, T element) { |
+ if (index is! int) throw new ArgumentError(index); |
srdjan
2013/03/04 00:53:47
Per Lars's instructions no explicit type checks sh
floitsch
2013/03/05 17:51:58
Done.
|
+ if (index < 0 || index > length) throw new RangeError(index); |
Lasse Reichstein Nielsen
2013/03/04 09:06:02
Consider special-casing index == length into 'add'
floitsch
2013/03/05 17:51:58
Done.
|
+ int newLength = this.length + 1; |
+ this.length = newLength; |
srdjan
2013/03/04 00:53:47
Why not just 'this.length+= 1;'?
Lasse Reichstein Nielsen
2013/03/04 09:06:02
Remember oldLength instead. It seems it's what you
floitsch
2013/03/05 17:51:58
Done.
|
+ Arrays.copy(this, |
+ index, |
+ this, |
+ index + 1, |
+ newLength - index - 1); |
+ this[index] = element; |
+ } |
+ |
T removeAt(int index) { |
if (index is! int) throw new ArgumentError(index); |
T result = this[index]; |