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

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

Issue 18023003: Add Map constructors taking iterables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/map.dart
diff --git a/sdk/lib/core/map.dart b/sdk/lib/core/map.dart
index 88776c12721b4d2bbd29211a4879799c4d8539bc..600217a2edafc48ecec6f80bea5d4a58a224153d 100644
--- a/sdk/lib/core/map.dart
+++ b/sdk/lib/core/map.dart
@@ -20,6 +20,28 @@ abstract class Map<K, V> {
factory Map.from(Map<K, V> other) => new HashMap<K, V>.from(other);
/**
+ * Creates a map where each key is an element from [keys] with
floitsch 2013/06/27 11:45:04 Try a shorter first sentence. More details in the
zarah 2013/06/27 13:02:43 Done.
+ * its associated value being the element from [values] at the same position.
+ *
+ * The length of [keys] and [values] must be the same, otherwise an ArgumentError
floitsch 2013/06/27 11:45:04 long line. We usually don't say what kind of erro
zarah 2013/06/27 13:02:43 Done.
+ * is thrown.
+ */
+ factory Map.fromIterables(Iterable<K> keys, Iterable<V> values)
+ = HashMap<K, V>.fromIterables;
+
+ /**
+ * Creates a map where each key-value pair is computed from each element in
floitsch 2013/06/27 11:45:04 Creates a [Map] where the keys and values are comp
zarah 2013/06/27 13:02:43 Done.
+ * [iterable]. The key is computed by applying the [key] function to the
+ * element and the value is computed by applying the [value] function to the
+ * same element.
+ *
+ * If no values are specified for [key] and [value] the default is the
+ * identity function.
+ */
+ factory Map.fromIterable(Iterable iterable,
+ {K key(element), V value(element)}) = HashMap<K, V>.fromIterable;
+
+ /**
* Returns whether this map contains the given [value].
*/
bool containsValue(Object value);

Powered by Google App Engine
This is Rietveld 408576698