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

Unified Diff: sdk/lib/collection/list.dart

Issue 14065011: Implement getRange (returning an Iterable). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes and status-file update. Created 7 years, 8 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: sdk/lib/collection/list.dart
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index 62bd84c5345e30111104f108799dc79c86936f01..dbf3355d8901cfc77ead2ceb8a5e5eec86a58db4 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -364,7 +364,15 @@ abstract class ListMixin<E> implements List<E> {
return result;
}
- List<E> getRange(int start, int length) => sublist(start, start + length);
+ Iterable<E> getRange(int start, int end) {
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
+ }
+ if (end < start || end > this.length) {
+ throw new RangeError.range(end, start, this.length);
+ }
+ return new SubListIterable(this, start, end);
+ }
void insertRange(int start, int length, [E initialValue]) {
if (start < 0 || start > this.length) {

Powered by Google App Engine
This is Rietveld 408576698