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

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

Issue 12817003: Change getRange to sublist. Make getRange deprecated. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 9 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_dev/list.dart
diff --git a/sdk/lib/_collection_dev/list.dart b/sdk/lib/_collection_dev/list.dart
index 7ae5abf93c8df7becb00b5d598a864d65c2ab5d9..01c7e8ad883803f9dc97b4902acc3f52508599c5 100644
--- a/sdk/lib/_collection_dev/list.dart
+++ b/sdk/lib/_collection_dev/list.dart
@@ -29,20 +29,24 @@ abstract class ListBase<E> extends ListIterable<E> implements List<E> {
return new ListMapView(this);
}
- List<E> getRange(int start, int length) {
+ List<E> sublist(int start, [int end]) {
+ if (end == null) end = length;
if (start < 0 || start > this.length) {
throw new RangeError.range(start, 0, this.length);
}
- if (length < 0 || start + length > this.length) {
- throw new RangeError.range(length, 0, this.length - start);
+ if (end < start || end > this.length) {
+ throw new RangeError.range(end, start, this.length);
}
- List<E> result = new List<E>(length);
+ int length = end - start;
+ List<E> result = new List<E>()..length = length;
for (int i = 0; i < length; i++) {
result[i] = this[start + i];
}
return result;
}
+ List<E> getRange(int start, int length) => sublist(start, start + length);
+
int indexOf(E element, [int start = 0]) {
return Arrays.indexOf(this, element, start, this.length);
}

Powered by Google App Engine
This is Rietveld 408576698