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

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

Issue 14175013: Add setAll, insertAll, replaceRange and fillRange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/core/list.dart
diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
index 8978978e68292b55653aee64b8b60044ac92d85d..59d4cd1730530b94d92c731c73c85e0772f79902 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -189,6 +189,30 @@ abstract class List<E> implements Iterable<E> {
void insert(int index, E element);
/**
+ * Inserts all elements of [iterable] at position [index] in the list.
+ *
+ * This increases the length of the list by the length of [iterable] and
+ * shifts all later elements towards the end of the list.
+ *
+ * It is an error if the [index] does not point inside the list or at the
+ * position after the last element.
+ */
+ void insertAll(int index, Iterable<E> iterable);
+
+ /**
+ * Overwrites elements of `this` with the elemenst of [iterable] starting
+ * at position [index] in the list.
+ *
+ * This operation does not increase the length of the list.
+ *
+ * It is an error if the [index] does not point inside the list or at the
+ * position after the last element.
+ *
+ * It is an error if the [iterable] is longer than [length] - [index].
Lasse Reichstein Nielsen 2013/04/15 12:03:08 How about not making it an error if the iterable i
floitsch 2013/04/15 16:22:48 Both are reasonable. I prefer the error since that
+ */
+ void setAll(int index, Iterable<E> iterable);
+
+ /**
* Removes [value] from the list. Returns true if [value] was
* in the list. Returns false otherwise. The method has no effect
* if [value] value was not in the list.
@@ -286,6 +310,30 @@ abstract class List<E> implements Iterable<E> {
void removeRange(int start, int end);
/**
+ * Sets the elements in the range [start]..[end] (excluding) to the given
+ * [fillValue].
+ *
+ * It is an error if [start]..[end] is not a valid range pointing into the
+ * `this`.
+ */
+ void fillRange(int start, int end, [E fillValue]);
+
+ /**
+ * Removes the elements in the range [start]..[end] (excluding) and replaces
+ * them with the contents of the [iterable].
+ *
+ * It is an error if [start]..[end] is not a valid range pointing into the
+ * `this`.
+ *
+ * Example:
+ *
+ * var list = [1, 2, 3, 4, 5];
+ * list.replaceRange(1, 3, [6, 7, 8, 9]);
+ * print(list); // [1, 6, 7, 8, 9, 4, 5]
+ */
+ void replaceRange(int start, int end, Iterable<E> iterable);
+
+ /**
* Returns an unmodifiable [Map] view of `this`.
*
* It has the indices of this list as keys, and the corresponding elements

Powered by Google App Engine
This is Rietveld 408576698