Chromium Code Reviews| Index: compiler/lib/implementation/array.dart |
| =================================================================== |
| --- compiler/lib/implementation/array.dart (revision 394) |
| +++ compiler/lib/implementation/array.dart (working copy) |
| @@ -120,6 +120,7 @@ |
| int get length() native; |
| void _setLength(int length) native; |
| void _add(T value) native; |
| + void _splice(int start, int length) native; |
| void forEach(void f(T element)) { |
| Collections.forEach(this, f); |
| @@ -150,11 +151,37 @@ |
| } |
| void setRange(int start, int length, List<T> from, [int startFrom = 0]) { |
| + if (_isFixed) { |
|
Anton Muhin
2011/10/18 07:44:20
may we have this in Arrays? Ditto for removeRange
ngeoffray
2011/10/18 07:46:09
There is a 'rangeCheck' method in Arrays.
Anton Muhin
2011/10/18 08:54:46
Sorry, I meant the whole logic of methods. Even f
ngeoffray
2011/10/18 08:58:01
The _splice is really tight to the implementation,
Anton Muhin
2011/10/18 14:33:49
I believe yes, but didn't double check. Anyway, l
|
| + throw const UnsupportedOperationException( |
| + "Cannot remove range of a non-extendable array"); |
| + } |
| + if (length == 0) { |
| + return; |
| + } |
| + if (length < 0) { |
| + throw const IllegalArgumentException(); |
| + } |
| Arrays.copy(from, startFrom, this, start, length); |
| } |
| void removeRange(int start, int length) { |
| - throw const NotImplementedException(); |
| + if (_isFixed) { |
| + throw const UnsupportedOperationException( |
| + "Cannot remove range of a non-extendable array"); |
| + } |
| + if (length == 0) { |
| + return; |
| + } |
| + if (length < 0) { |
| + throw const IllegalArgumentException(); |
| + } |
| + if (start < 0 || start >= this.length) { |
| + throw new IndexOutOfRangeException(start); |
| + } |
| + if (start + length > this.length) { |
| + throw new IndexOutOfRangeException(start + length); |
| + } |
| + _splice(start, length); |
| } |
| void insertRange(int start, int length, [T initialValue = null]) { |