OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.collection; | 5 part of dart.collection; |
6 | 6 |
7 /** Default function for equality comparison in customized HashMaps */ | 7 /** Default function for equality comparison in customized HashMaps */ |
8 bool _defaultEquals(a, b) => a == b; | 8 bool _defaultEquals(a, b) => a == b; |
9 /** Default function for hash-code computation in customized HashMaps */ | 9 /** Default function for hash-code computation in customized HashMaps */ |
10 int _defaultHashCode(a) => a.hashCode; | 10 int _defaultHashCode(a) => a.hashCode; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 * new HashMap(equals: identical, | 95 * new HashMap(equals: identical, |
96 * hashCode: identityHashCode) | 96 * hashCode: identityHashCode) |
97 */ | 97 */ |
98 external factory HashMap.identity(); | 98 external factory HashMap.identity(); |
99 | 99 |
100 /** | 100 /** |
101 * Creates a [HashMap] that contains all key/value pairs of [other]. | 101 * Creates a [HashMap] that contains all key/value pairs of [other]. |
102 */ | 102 */ |
103 factory HashMap.from(Map other) { | 103 factory HashMap.from(Map other) { |
104 HashMap<K, V> result = new HashMap<K, V>(); | 104 HashMap<K, V> result = new HashMap<K, V>(); |
105 other.forEach((k, v) { result[k] = v; }); | 105 other.forEach((k, v) { result[k as Object/*=K*/] = v as Object/*=V*/; }); |
106 return result; | 106 return result; |
107 } | 107 } |
108 | 108 |
109 /** | 109 /** |
110 * Creates a [HashMap] where the keys and values are computed from the | 110 * Creates a [HashMap] where the keys and values are computed from the |
111 * [iterable]. | 111 * [iterable]. |
112 * | 112 * |
113 * For each element of the [iterable] this constructor computes a key/value | 113 * For each element of the [iterable] this constructor computes a key/value |
114 * pair, by applying [key] and [value] respectively. | 114 * pair, by applying [key] and [value] respectively. |
115 * | 115 * |
(...skipping 20 matching lines...) Expand all Loading... |
136 * overwrites the previous value. | 136 * overwrites the previous value. |
137 * | 137 * |
138 * It is an error if the two [Iterable]s don't have the same length. | 138 * It is an error if the two [Iterable]s don't have the same length. |
139 */ | 139 */ |
140 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { | 140 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { |
141 HashMap<K, V> map = new HashMap<K, V>(); | 141 HashMap<K, V> map = new HashMap<K, V>(); |
142 Maps._fillMapWithIterables(map, keys, values); | 142 Maps._fillMapWithIterables(map, keys, values); |
143 return map; | 143 return map; |
144 } | 144 } |
145 } | 145 } |
OLD | NEW |