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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 */ | 85 */ |
86 external factory HashMap({bool equals(K key1, K key2), | 86 external factory HashMap({bool equals(K key1, K key2), |
87 int hashCode(K key), | 87 int hashCode(K key), |
88 bool isValidKey(potentialKey)}); | 88 bool isValidKey(potentialKey)}); |
89 | 89 |
90 /** | 90 /** |
91 * Creates an unordered identity-based map. | 91 * Creates an unordered identity-based map. |
92 * | 92 * |
93 * Effectively a shorthand for: | 93 * Effectively a shorthand for: |
94 * | 94 * |
95 * new HashMap(equals: identical, | 95 * new HashMap<K, V>(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 as Object/*=K*/] = v as Object/*=V*/; }); | 105 other.forEach((k, v) { result[k as Object/*=K*/] = v as Object/*=V*/; }); |
106 return result; | 106 return result; |
(...skipping 29 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 |