Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1432)

Unified Diff: compiler/lib/implementation/array.dart

Issue 8273004: Implement removeRange, and update some documentation on the list interface. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiler/lib/implementation/array.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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]) {
« no previous file with comments | « no previous file | compiler/lib/implementation/array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698