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

Side by Side Diff: sdk/lib/core/map.dart

Issue 22966015: Revert "Make Map constructors return LinkedHashMap." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
« no previous file with comments | « sdk/lib/collection/linked_hash_map.dart ('k') | tests/corelib/map_from_iterable_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * An unordered collection of key-value pairs, 8 * An unordered collection of key-value pairs,
9 * from which you retrieve a value by using its associated key. 9 * from which you retrieve a value by using its associated key.
10 * 10 *
11 * Each key must be unique. 11 * Each key must be unique.
12 * Null values are supported, but null keys are not. 12 * Null values are supported, but null keys are not.
13 */ 13 */
14 abstract class Map<K, V> { 14 abstract class Map<K, V> {
15 /** 15 /**
16 * Creates a Map instance with the default implementation. 16 * Creates a Map instance with the default implementation.
17 */ 17 */
18 factory Map() = LinkedHashMap<K, V>; 18 factory Map() => new HashMap<K, V>();
19 19
20 /** 20 /**
21 * Creates a Map instance that contains all key-value pairs of [other]. 21 * Creates a Map instance that contains all key-value pairs of [other].
22 */ 22 */
23 factory Map.from(Map<K, V> other) = LinkedHashMap<K, V>.from; 23 factory Map.from(Map<K, V> other) => new HashMap<K, V>.from(other);
24 24
25 /** 25 /**
26 * Creates a Map instance 26 * Creates a Map instance
27 * where the keys and values are computed from the [iterable]. 27 * where the keys and values are computed from the [iterable].
28 * 28 *
29 * For each element of the [iterable] this constructor computes a key-value 29 * For each element of the [iterable] this constructor computes a key-value
30 * pair, by applying [key] and [value] respectively. 30 * pair, by applying [key] and [value] respectively.
31 * 31 *
32 * The keys computed by the source [iterable] 32 * The keys computed by the source [iterable]
33 * do not need to be unique. The last 33 * do not need to be unique. The last
34 * occurrence of a key will simply overwrite any previous value. 34 * occurrence of a key will simply overwrite any previous value.
35 * 35 *
36 * If no values are specified for [key] and [value] the default is the 36 * If no values are specified for [key] and [value] the default is the
37 * identity function. 37 * identity function.
38 */ 38 */
39 factory Map.fromIterable(Iterable<K> iterable, 39 factory Map.fromIterable(Iterable<K> iterable,
40 {K key(element), V value(element)}) = LinkedHashMap<K, V>.fromIterable; 40 {K key(element), V value(element)}) = HashMap<K, V>.fromIterable;
41 41
42 /** 42 /**
43 * Creates a Map instance associating the given [keys] to [values]. 43 * Creates a Map instance associating the given [keys] to [values].
44 * 44 *
45 * This constructor iterates over [keys] and [values] and maps each element of 45 * This constructor iterates over [keys] and [values] and maps each element of
46 * [keys] to the corresponding element of [values]. 46 * [keys] to the corresponding element of [values].
47 * 47 *
48 * If [keys] contains the same object multiple times, the last occurrence 48 * If [keys] contains the same object multiple times, the last occurrence
49 * overwrites the previous value. 49 * overwrites the previous value.
50 * 50 *
51 * It is an error if the two [Iterable]s don't have the same length. 51 * It is an error if the two [Iterable]s don't have the same length.
52 */ 52 */
53 factory Map.fromIterables(Iterable<K> keys, Iterable<V> values) 53 factory Map.fromIterables(Iterable<K> keys, Iterable<V> values)
54 = LinkedHashMap<K, V>.fromIterables; 54 = HashMap<K, V>.fromIterables;
55 55
56 /** 56 /**
57 * Returns true if this map contains the given value. 57 * Returns true if this map contains the given value.
58 */ 58 */
59 bool containsValue(Object value); 59 bool containsValue(Object value);
60 60
61 /** 61 /**
62 * Returns true if this map contains the given key. 62 * Returns true if this map contains the given key.
63 */ 63 */
64 bool containsKey(Object key); 64 bool containsKey(Object key);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 /** 135 /**
136 * Returns true if there is no {key, value} pair in the map. 136 * Returns true if there is no {key, value} pair in the map.
137 */ 137 */
138 bool get isEmpty; 138 bool get isEmpty;
139 139
140 /** 140 /**
141 * Returns true if there is at least one {key, value} pair in the map. 141 * Returns true if there is at least one {key, value} pair in the map.
142 */ 142 */
143 bool get isNotEmpty; 143 bool get isNotEmpty;
144 } 144 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/linked_hash_map.dart ('k') | tests/corelib/map_from_iterable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698