Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 * | 56 * |
| 57 * It is generally the case that if you supply one of [equals] and [hashCode], | 57 * It is generally the case that if you supply one of [equals] and [hashCode], |
| 58 * you also want to supply the other. The only common exception is to pass | 58 * you also want to supply the other. The only common exception is to pass |
| 59 * [identical] as the equality and use the default hash code. | 59 * [identical] as the equality and use the default hash code. |
| 60 */ | 60 */ |
| 61 external factory HashMap({bool equals(K key1, K key2), | 61 external factory HashMap({bool equals(K key1, K key2), |
| 62 int hashCode(K key), | 62 int hashCode(K key), |
| 63 bool isValidKey(potentialKey)}); | 63 bool isValidKey(potentialKey)}); |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Creates an unordered identity-based map. | |
| 67 * | |
| 68 * Effectively a shorthand for: | |
| 69 * new HashMap(equals: identical, hashCode: identityHashCodeOf) | |
|
floitsch
2013/09/24 15:45:46
Not sure if there needs to be a new-line before th
Lasse Reichstein Nielsen
2013/09/25 09:37:05
Line seems to be needed.
| |
| 70 */ | |
| 71 external factory HashMap.identity(); | |
| 72 | |
| 73 /** | |
| 66 * Creates a [HashMap] that contains all key value pairs of [other]. | 74 * Creates a [HashMap] that contains all key value pairs of [other]. |
| 67 */ | 75 */ |
| 68 factory HashMap.from(Map<K, V> other) { | 76 factory HashMap.from(Map<K, V> other) { |
| 69 return new HashMap<K, V>()..addAll(other); | 77 return new HashMap<K, V>()..addAll(other); |
| 70 } | 78 } |
| 71 | 79 |
| 72 /** | 80 /** |
| 73 * Creates a [HashMap] where the keys and values are computed from the | 81 * Creates a [HashMap] where the keys and values are computed from the |
| 74 * [iterable]. | 82 * [iterable]. |
| 75 * | 83 * |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 99 * overwrites the previous value. | 107 * overwrites the previous value. |
| 100 * | 108 * |
| 101 * It is an error if the two [Iterable]s don't have the same length. | 109 * It is an error if the two [Iterable]s don't have the same length. |
| 102 */ | 110 */ |
| 103 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { | 111 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { |
| 104 HashMap<K, V> map = new HashMap<K, V>(); | 112 HashMap<K, V> map = new HashMap<K, V>(); |
| 105 Maps._fillMapWithIterables(map, keys, values); | 113 Maps._fillMapWithIterables(map, keys, values); |
| 106 return map; | 114 return map; |
| 107 } | 115 } |
| 108 } | 116 } |
| OLD | NEW |