Index: sdk/lib/collection/linked_hash_map.dart |
diff --git a/sdk/lib/collection/linked_hash_map.dart b/sdk/lib/collection/linked_hash_map.dart |
index e1bca0f509645ba2441fb12b13028ee64768bc1c..e06f9e6644ea24573404a6f588965713579689d4 100644 |
--- a/sdk/lib/collection/linked_hash_map.dart |
+++ b/sdk/lib/collection/linked_hash_map.dart |
@@ -43,6 +43,25 @@ abstract class LinkedHashMap<K, V> implements HashMap<K, V> { |
* The [isValidKey] function defaults to just testing if the object is a |
* [K] instance. |
* |
+ * Example: |
+ * |
+ * new LinkedHashMap<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 [LinkedHashMap.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 |
@@ -50,19 +69,18 @@ abstract class LinkedHashMap<K, V> implements HashMap<K, V> { |
* |
* 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 [LinkedHashMap.identity]). |
*/ |
- external factory LinkedHashMap({ bool equals(K key1, K key2), |
- int hashCode(K key), |
- bool isValidKey(potentialKey) }); |
+ external factory LinkedHashMap({bool equals(K key1, K key2), |
+ int hashCode(K key), |
+ bool isValidKey(potentialKey)}); |
/** |
* Creates an insertion-ordered identity-based map. |
* |
* Effectively a shorthand for: |
* |
- * new LinkedHashMap(equals: identical, hashCode: identityHashCodeOf) |
+ * new LinkedHashMap(equals: identical, |
+ * hashCode: identityHashCodeOf) |
*/ |
external factory LinkedHashMap.identity(); |