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

Unified Diff: runtime/lib/growable_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
Index: runtime/lib/growable_array.dart
===================================================================
--- runtime/lib/growable_array.dart (revision 394)
+++ runtime/lib/growable_array.dart (working copy)
@@ -10,11 +10,29 @@
}
void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
+ if (length < 0) throw new IllegalArgumentException(length);
Arrays.copy(from, startFrom, this, start, length);
}
void removeRange(int start, int length) {
- throw const NotImplementedException();
+ 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);
+ }
+ Arrays.copy(backingArray,
+ start + length,
+ backingArray,
+ start,
+ this.length - length - start);
+ this.length = this.length - length;
}
void insertRange(int start, int length, [T initialValue = null]) {

Powered by Google App Engine
This is Rietveld 408576698