Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: test/generated_sdk/lib/collection/hash_map.dart

Issue 1122313002: Typing fixes to eliminate casts/dcalls (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(Object a, Object 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(Object a) => a.hashCode;
11 11
12 /** Type of custom equality function */ 12 /** Type of custom equality function */
13 typedef bool _Equality<K>(K a, K b); 13 typedef bool _Equality<K>(K a, K b);
14 /** Type of custom hash code function. */ 14 /** Type of custom hash code function. */
15 typedef int _Hasher<K>(K object); 15 typedef int _Hasher<K>(K object);
16 16
17 /** 17 /**
18 * A hash-table based implementation of [Map]. 18 * A hash-table based implementation of [Map].
19 * 19 *
20 * The keys of a `HashMap` must have consistent [Object.operator==] 20 * The keys of a `HashMap` must have consistent [Object.operator==]
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 * of an object, or what it compares equal to, should not change while the 61 * of an object, or what it compares equal to, should not change while the
62 * object is in the table. If it does change, the result is unpredictable. 62 * object is in the table. If it does change, the result is unpredictable.
63 * 63 *
64 * If you supply one of [equals] and [hashCode], 64 * If you supply one of [equals] and [hashCode],
65 * you should generally also to supply the other. 65 * you should generally also to supply the other.
66 * An example would be using [identical] and [identityHashCode], 66 * An example would be using [identical] and [identityHashCode],
67 * which is equivalent to using the shorthand [HashMap.identity]). 67 * which is equivalent to using the shorthand [HashMap.identity]).
68 */ 68 */
69 factory HashMap({ bool equals(K key1, K key2), 69 factory HashMap({ bool equals(K key1, K key2),
70 int hashCode(K key), 70 int hashCode(K key),
71 bool isValidKey(potentialKey) }) { 71 bool isValidKey(Object potentialKey) }) {
72 if (isValidKey == null) { 72 if (isValidKey == null) {
73 if (hashCode == null) { 73 if (hashCode == null) {
74 if (equals == null) { 74 if (equals == null) {
75 return new _HashMap<K, V>(); 75 return new _HashMap<K, V>();
76 } 76 }
77 hashCode = _defaultHashCode; 77 hashCode = _defaultHashCode;
78 } else { 78 } else {
79 if (identical(identityHashCode, hashCode) && 79 if (identical(identityHashCode, hashCode) &&
80 identical(identical, equals)) { 80 identical(identical, equals)) {
81 return new _IdentityHashMap<K, V>(); 81 return new _IdentityHashMap<K, V>();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 * overwrites the previous value. 143 * overwrites the previous value.
144 * 144 *
145 * It is an error if the two [Iterable]s don't have the same length. 145 * It is an error if the two [Iterable]s don't have the same length.
146 */ 146 */
147 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { 147 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) {
148 HashMap<K, V> map = new HashMap<K, V>(); 148 HashMap<K, V> map = new HashMap<K, V>();
149 Maps._fillMapWithIterables(map, keys, values); 149 Maps._fillMapWithIterables(map, keys, values);
150 return map; 150 return map;
151 } 151 }
152 } 152 }
OLDNEW
« no previous file with comments | « test/generated_sdk/lib/collection/collection.dart ('k') | test/generated_sdk/lib/collection/hash_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698