| Index: tool/input_sdk/lib/collection/hash_map.dart
|
| diff --git a/tool/input_sdk/lib/collection/hash_map.dart b/tool/input_sdk/lib/collection/hash_map.dart
|
| index 003cd4f18c8b642fe3df060d72093d26a57fb77c..dacf929e0ac2e9687b3e8e60f0961e6b7e24faad 100644
|
| --- a/tool/input_sdk/lib/collection/hash_map.dart
|
| +++ b/tool/input_sdk/lib/collection/hash_map.dart
|
| @@ -5,9 +5,9 @@
|
| part of dart.collection;
|
|
|
| /** Default function for equality comparison in customized HashMaps */
|
| -bool _defaultEquals(Object a, Object b) => a == b;
|
| +bool _defaultEquals(a, b) => a == b;
|
| /** Default function for hash-code computation in customized HashMaps */
|
| -int _defaultHashCode(Object a) => a.hashCode;
|
| +int _defaultHashCode(a) => a.hashCode;
|
|
|
| /** Type of custom equality function */
|
| typedef bool _Equality<K>(K a, K b);
|
| @@ -27,7 +27,7 @@ typedef int _Hasher<K>(K object);
|
| *
|
| * Iterating the map's keys, values or entries (through [forEach])
|
| * may happen in any order.
|
| - * The itearation order only changes when the map is modified.
|
| + * The iteration order only changes when the map is modified.
|
| * Values are iterated in the same order as their associated keys,
|
| * so iterating the [keys] and [values] in parallel
|
| * will give matching key and value pairs.
|
| @@ -56,15 +56,32 @@ abstract class HashMap<K, V> implements Map<K, V> {
|
| * The [isValidKey] function defaults to just testing if the object is a
|
| * [K] instance.
|
| *
|
| + * Example:
|
| + *
|
| + * new HashMap<int,int>(equals: (int a, int b) => (b - a) % 5 == 0,
|
| + * hashCode: (int e) => e % 5)
|
| + *
|
| + * This example map does not need an `isValidKey` function to be passed.
|
| + * The default function accepts only `int` values, which can safely be
|
| + * passed to both the `equals` and `hashCode` functions.
|
| + *
|
| + * If neither `equals`, `hashCode`, nor `isValidKey` is provided,
|
| + * the default `isValidKey` instead accepts all keys.
|
| + * The default equality and hashcode operations are assumed to work on all
|
| + * objects.
|
| + *
|
| + * Likewise, if `equals` is [identical], `hashCode` is [identityHashCode]
|
| + * and `isValidKey` is omitted, the resulting map is identity based,
|
| + * and the `isValidKey` defaults to accepting all keys.
|
| + * Such a map can be created directly using [HashMap.identity].
|
| + *
|
| * The used `equals` and `hashCode` method should always be consistent,
|
| * so that if `equals(a, b)` then `hashCode(a) == hashCode(b)`. The hash
|
| * of an object, or what it compares equal to, should not change while the
|
| - * object is in the table. If it does change, the result is unpredictable.
|
| + * object is a key in the map. If it does change, the result is unpredictable.
|
| *
|
| * If you supply one of [equals] and [hashCode],
|
| * you should generally also to supply the other.
|
| - * An example would be using [identical] and [identityHashCode],
|
| - * which is equivalent to using the shorthand [HashMap.identity]).
|
| */
|
| external factory HashMap({bool equals(K key1, K key2),
|
| int hashCode(K key),
|
| @@ -75,7 +92,8 @@ abstract class HashMap<K, V> implements Map<K, V> {
|
| *
|
| * Effectively a shorthand for:
|
| *
|
| - * new HashMap(equals: identical, hashCode: identityHashCodeOf)
|
| + * new HashMap(equals: identical,
|
| + * hashCode: identityHashCode)
|
| */
|
| external factory HashMap.identity();
|
|
|
| @@ -84,7 +102,7 @@ abstract class HashMap<K, V> implements Map<K, V> {
|
| */
|
| factory HashMap.from(Map other) {
|
| HashMap<K, V> result = new HashMap<K, V>();
|
| - other.forEach((k, v) { result[k] = v; });
|
| + other.forEach((k, v) { result[k as K] = v as V; });
|
| return result;
|
| }
|
|
|
|
|