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

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

Issue 11312122: Change List constructors. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload. Adapt code for List.fixedLength. Created 8 years 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/async/future_impl.dart ('k') | sdk/lib/core/map.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 fb156af3401129174dc5ca06f8cca0a220869d29..199301b6775dd8b2894f2ee4365237e016aa7b64 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -11,17 +11,29 @@ interface List<E> extends Collection<E>, Sequence<E>
/**
* Creates a list of the given [length].
*
- * If no [length] argument is supplied an extendable list of
- * length 0 is created.
+ * The length of the returned list is not fixed.
+ */
+ List([int length = 0]);
+
+ /**
+ * Creates a fixed-sized list of the given [length] where each entry is
+ * filled with [fill].
+ */
+ List.fixedLength(int length, {E fill: null});
+
+ /**
+ * Creates an list of the given [length] where each entry is
+ * filled with [fill].
*
- * If a [length] argument is supplied, a fixed size list of that
- * length is created.
+ * The length of the returned list is not fixed.
*/
- List([int length]);
+ List.filled(int length, E fill);
/**
- * Creates a list with the elements of [other]. The order in
+ * Creates an list with the elements of [other]. The order in
* the list will be the order provided by the iterator of [other].
+ *
+ * The length of the returned list is not fixed.
*/
List.from(Iterable<E> other);
@@ -167,7 +179,7 @@ interface List<E> extends Collection<E>, Sequence<E>
/**
* Inserts a new range into the list, starting from [start] to
- * [:start + length - 1:]. The entries are filled with [initialValue].
+ * [:start + length - 1:]. The entries are filled with [fill].
* Throws an [UnsupportedError] if the list is
* not extendable.
* If [length] is 0, this method does not do anything.
@@ -177,16 +189,28 @@ interface List<E> extends Collection<E>, Sequence<E>
* Throws an [RangeError] if [start] is negative or if
* [start] is greater than the length of the list.
*/
- void insertRange(int start, int length, [E initialValue]);
+ void insertRange(int start, int length, [E fill]);
}
class _ListImpl<E> {
/**
* Factory implementation of List().
*
- * Creates a list of the given [length].
+ * Creates an extendable list of the given [length].
+ */
+ external factory List([int length = 0]);
+
+ /**
+ * Creates a fixed-sized list of the given [length] where each entry is
+ * filled with [fill].
+ */
+ external factory List.fixedLength(int length, {E fill: null});
+
+ /**
+ * Creates an extendable list of the given [length] where each entry is
+ * filled with [fill].
*/
- external factory List([int length]);
+ external factory List.filled(int length, E fill);
/**
* Factory implementation of List.from().
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | sdk/lib/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698