| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 76    * Such a map can be created directly using [HashMap.identity]. | 76    * Such a map can be created directly using [HashMap.identity]. | 
| 77    * | 77    * | 
| 78    * The used `equals` and `hashCode` method should always be consistent, | 78    * The used `equals` and `hashCode` method should always be consistent, | 
| 79    * so that if `equals(a, b)` then `hashCode(a) == hashCode(b)`. The hash | 79    * so that if `equals(a, b)` then `hashCode(a) == hashCode(b)`. The hash | 
| 80    * of an object, or what it compares equal to, should not change while the | 80    * of an object, or what it compares equal to, should not change while the | 
| 81    * object is a key in the map. If it does change, the result is unpredictable. | 81    * object is a key in the map. If it does change, the result is unpredictable. | 
| 82    * | 82    * | 
| 83    * If you supply one of [equals] and [hashCode], | 83    * If you supply one of [equals] and [hashCode], | 
| 84    * you should generally also to supply the other. | 84    * you should generally also to supply the other. | 
| 85    */ | 85    */ | 
| 86   external factory HashMap({bool equals(K key1, K key2), | 86   external factory HashMap( | 
| 87                             int hashCode(K key), | 87       {bool equals(K key1, K key2), | 
| 88                             bool isValidKey(potentialKey)}); | 88       int hashCode(K key), | 
|  | 89       bool isValidKey(potentialKey)}); | 
| 89 | 90 | 
| 90   /** | 91   /** | 
| 91    * Creates an unordered identity-based map. | 92    * Creates an unordered identity-based map. | 
| 92    * | 93    * | 
| 93    * Effectively a shorthand for: | 94    * Effectively a shorthand for: | 
| 94    * | 95    * | 
| 95    *     new HashMap<K, V>(equals: identical, | 96    *     new HashMap<K, V>(equals: identical, | 
| 96    *                       hashCode: identityHashCode) | 97    *                       hashCode: identityHashCode) | 
| 97    */ | 98    */ | 
| 98   external factory HashMap.identity(); | 99   external factory HashMap.identity(); | 
| 99 | 100 | 
| 100   /** | 101   /** | 
| 101    * Creates a [HashMap] that contains all key/value pairs of [other]. | 102    * Creates a [HashMap] that contains all key/value pairs of [other]. | 
| 102    */ | 103    */ | 
| 103   factory HashMap.from(Map other) { | 104   factory HashMap.from(Map other) { | 
| 104     HashMap<K, V> result = new HashMap<K, V>(); | 105     HashMap<K, V> result = new HashMap<K, V>(); | 
| 105     other.forEach((k, v) { result[k as Object/*=K*/] = v as Object/*=V*/; }); | 106     other.forEach((k, v) { | 
|  | 107       result[k as Object/*=K*/] = v as Object/*=V*/; | 
|  | 108     }); | 
| 106     return result; | 109     return result; | 
| 107   } | 110   } | 
| 108 | 111 | 
| 109   /** | 112   /** | 
| 110    * Creates a [HashMap] where the keys and values are computed from the | 113    * Creates a [HashMap] where the keys and values are computed from the | 
| 111    * [iterable]. | 114    * [iterable]. | 
| 112    * | 115    * | 
| 113    * For each element of the [iterable] this constructor computes a key/value | 116    * For each element of the [iterable] this constructor computes a key/value | 
| 114    * pair, by applying [key] and [value] respectively. | 117    * pair, by applying [key] and [value] respectively. | 
| 115    * | 118    * | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 136    * overwrites the previous value. | 139    * overwrites the previous value. | 
| 137    * | 140    * | 
| 138    * It is an error if the two [Iterable]s don't have the same length. | 141    * It is an error if the two [Iterable]s don't have the same length. | 
| 139    */ | 142    */ | 
| 140   factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { | 143   factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { | 
| 141     HashMap<K, V> map = new HashMap<K, V>(); | 144     HashMap<K, V> map = new HashMap<K, V>(); | 
| 142     Maps._fillMapWithIterables(map, keys, values); | 145     Maps._fillMapWithIterables(map, keys, values); | 
| 143     return map; | 146     return map; | 
| 144   } | 147   } | 
| 145 } | 148 } | 
| OLD | NEW | 
|---|