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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A [Map] is an associative container, mapping a key to a value. 8 * A [Map] is an associative container, mapping a key to a value.
9 * Null values are supported, but null keys are not. 9 * Null values are supported, but null keys are not.
10 */ 10 */
11 abstract class Map<K, V> { 11 abstract class Map<K, V> {
12 /** 12 /**
13 * Creates a map with the default implementation. 13 * Creates a map with the default implementation.
14 */ 14 */
15 factory Map() => new HashMap<K, V>(); 15 factory Map() => new HashMap<K, V>();
16 16
17 /** 17 /**
18 * Creates a [Map] that contains all key value pairs of [other]. 18 * Creates a [Map] that contains all key value pairs of [other].
19 */ 19 */
20 factory Map.from(Map<K, V> other) => new HashMap<K, V>.from(other); 20 factory Map.from(Map<K, V> other) => new HashMap<K, V>.from(other);
21 21
22 /** 22 /**
23 * 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.
24 * its associated value being the element from [values] at the same position.
25 *
26 * The length of [keys] and [values] must be the same, otherwise an ArgumentEr ror
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.
27 * is thrown.
28 */
29 factory Map.fromIterables(Iterable<K> keys, Iterable<V> values)
30 = HashMap<K, V>.fromIterables;
31
32 /**
33 * 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.
34 * [iterable]. The key is computed by applying the [key] function to the
35 * element and the value is computed by applying the [value] function to the
36 * same element.
37 *
38 * If no values are specified for [key] and [value] the default is the
39 * identity function.
40 */
41 factory Map.fromIterable(Iterable iterable,
42 {K key(element), V value(element)}) = HashMap<K, V>.fromIterable;
43
44 /**
23 * Returns whether this map contains the given [value]. 45 * Returns whether this map contains the given [value].
24 */ 46 */
25 bool containsValue(Object value); 47 bool containsValue(Object value);
26 48
27 /** 49 /**
28 * Returns whether this map contains the given [key]. 50 * Returns whether this map contains the given [key].
29 */ 51 */
30 bool containsKey(Object key); 52 bool containsKey(Object key);
31 53
32 /** 54 /**
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 /** 123 /**
102 * Returns true if there is no {key, value} pair in the map. 124 * Returns true if there is no {key, value} pair in the map.
103 */ 125 */
104 bool get isEmpty; 126 bool get isEmpty;
105 127
106 /** 128 /**
107 * Returns true if there is at least one {key, value} pair in the map. 129 * Returns true if there is at least one {key, value} pair in the map.
108 */ 130 */
109 bool get isNotEmpty; 131 bool get isNotEmpty;
110 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698