| 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 /** | 7 /** |
| 8 * A hash-table based implementation of [Map]. | 8 * A hash-table based implementation of [Map]. |
| 9 * | 9 * |
| 10 * The insertion order of keys is remembered, | 10 * The insertion order of keys is remembered, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 * of an object, or what it compares equal to, should not change while the | 48 * of an object, or what it compares equal to, should not change while the |
| 49 * object is in the table. If it does change, the result is unpredictable. | 49 * object is in the table. If it does change, the result is unpredictable. |
| 50 * | 50 * |
| 51 * If you supply one of [equals] and [hashCode], | 51 * If you supply one of [equals] and [hashCode], |
| 52 * you should generally also to supply the other. | 52 * you should generally also to supply the other. |
| 53 * An example would be using [identical] and [identityHashCode], | 53 * An example would be using [identical] and [identityHashCode], |
| 54 * which is equivalent to using the shorthand [LinkedHashMap.identity]). | 54 * which is equivalent to using the shorthand [LinkedHashMap.identity]). |
| 55 */ | 55 */ |
| 56 factory LinkedHashMap({ bool equals(K key1, K key2), | 56 factory LinkedHashMap({ bool equals(K key1, K key2), |
| 57 int hashCode(K key), | 57 int hashCode(K key), |
| 58 bool isValidKey(potentialKey) }) { | 58 bool isValidKey(Object potentialKey) }) { |
| 59 if (isValidKey == null) { | 59 if (isValidKey == null) { |
| 60 if (hashCode == null) { | 60 if (hashCode == null) { |
| 61 if (equals == null) { | 61 if (equals == null) { |
| 62 return new _LinkedHashMap<K, V>(); | 62 return new _LinkedHashMap<K, V>(); |
| 63 } | 63 } |
| 64 hashCode = _defaultHashCode; | 64 hashCode = _defaultHashCode; |
| 65 } else { | 65 } else { |
| 66 if (identical(identityHashCode, hashCode) && | 66 if (identical(identityHashCode, hashCode) && |
| 67 identical(identical, equals)) { | 67 identical(identical, equals)) { |
| 68 return new _LinkedIdentityHashMap<K, V>(); | 68 return new _LinkedIdentityHashMap<K, V>(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 @NoInline() | 140 @NoInline() |
| 141 factory LinkedHashMap._literal(List keyValuePairs) { | 141 factory LinkedHashMap._literal(List keyValuePairs) { |
| 142 return fillLiteralMap(keyValuePairs, new _LinkedHashMap<K, V>()); | 142 return fillLiteralMap(keyValuePairs, new _LinkedHashMap<K, V>()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 @NoThrows() @NoInline() | 145 @NoThrows() @NoInline() |
| 146 factory LinkedHashMap._empty() { | 146 factory LinkedHashMap._empty() { |
| 147 return new _LinkedHashMap<K, V>(); | 147 return new _LinkedHashMap<K, V>(); |
| 148 } | 148 } |
| 149 } | 149 } |
| OLD | NEW |