| Index: compiler/lib/implementation/array.dart
|
| ===================================================================
|
| --- compiler/lib/implementation/array.dart (revision 424)
|
| +++ compiler/lib/implementation/array.dart (working copy)
|
| @@ -120,7 +120,8 @@
|
| int get length() native;
|
| void _setLength(int length) native;
|
| void _add(T value) native;
|
| - void _splice(int start, int length) native;
|
| + void _removeRange(int start, int length) native;
|
| + void _insertRange(int start, int length, T initialValue) native;
|
|
|
| void forEach(void f(T element)) {
|
| Collections.forEach(this, f);
|
| @@ -158,9 +159,7 @@
|
| if (length == 0) {
|
| return;
|
| }
|
| - if (length < 0) {
|
| - throw new IllegalArgumentException("negative length $length");
|
| - }
|
| + Arrays.rangeCheck(this, start, length);
|
| Arrays.copy(from, startFrom, this, start, length);
|
| }
|
|
|
| @@ -172,22 +171,27 @@
|
| if (length == 0) {
|
| return;
|
| }
|
| + Arrays.rangeCheck(this, start, length);
|
| + _removeRange(start, length);
|
| + }
|
| +
|
| + void insertRange(int start, int length, [T initialValue = null]) {
|
| + if (_isFixed) {
|
| + throw const UnsupportedOperationException(
|
| + "Cannot insert range in a non-extendable array");
|
| + }
|
| + if (length == 0) {
|
| + return;
|
| + }
|
| if (length < 0) {
|
| throw new IllegalArgumentException("negative length $length");
|
| }
|
| - if (start < 0 || start >= this.length) {
|
| + if (start < 0 || start > this.length) {
|
| throw new IndexOutOfRangeException(start);
|
| }
|
| - if (start + length > this.length) {
|
| - throw new IndexOutOfRangeException(start + length);
|
| - }
|
| - _splice(start, length);
|
| + _insertRange(start, length, initialValue);
|
| }
|
|
|
| - void insertRange(int start, int length, [T initialValue = null]) {
|
| - throw const NotImplementedException();
|
| - }
|
| -
|
| List<T> getRange(int start, int length) {
|
| if (length == 0) return [];
|
| Arrays.rangeCheck(this, start, length);
|
|
|