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

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

Issue 14065011: Implement getRange (returning an Iterable). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/list.dart
diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
index 12b8aedfb5baa03647163e15411c0d14f47aaa2b..c0f15698e0e76227942872adc9414469e5679fd1 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -222,7 +222,7 @@ abstract class List<E> implements Collection<E> {
E removeLast();
/**
- * Returns a new list containing the elemenst from [start] to [end].
+ * Returns a new list containing the elements from [start] to [end].
*
* If [end] is omitted, the [length] of the list is used.
*
@@ -232,10 +232,26 @@ abstract class List<E> implements Collection<E> {
List<E> sublist(int start, [int end]);
/**
- * *Deprecated*. Use [sublist] instead.
+ * Returns an [Iterable] that iterators over the elements in the range
+ * [start] to [end] (exclusive). The result of this function is backed by
+ * `this`.
+ *
+ * It is an error if [end] is before [start].
+ *
+ * It is an error if the [start] and [end] are not valid ranges at the time
+ * of the call to this method. The returned [Iterable] behaves similar to
+ * `skip(start).take(end - start)`. That is, it will not throw exceptions
+ * if `this` changes size.
+ *
+ * Example:
+ *
+ * var list = [1, 2, 3, 4, 5];
+ * var range = list.getRange(1, 4);
+ * print(range.join(', ')); // => 2, 3, 4
+ * list.length = 3;
+ * print(range.join(', ')); // => 2, 3
*/
- @deprecated
- List<E> getRange(int start, int length);
+ Iterable<E> getRange(int start, int end);
/**
* Copies [length] elements of [from], starting
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698