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

Side by Side Diff: sdk/lib/collection/hash_map.dart

Issue 24267023: Update implementations to use Object.identityHashCode for identity map/set (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Add tests. Fix few bugs now that it can run. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/lib/collection_patch.dart ('k') | sdk/lib/collection/hash_set.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 * 56 *
57 * It is generally the case that if you supply one of [equals] and [hashCode], 57 * It is generally the case that if you supply one of [equals] and [hashCode],
58 * you also want to supply the other. The only common exception is to pass 58 * you also want to supply the other. The only common exception is to pass
59 * [identical] as the equality and use the default hash code. 59 * [identical] as the equality and use the default hash code.
60 */ 60 */
61 external factory HashMap({bool equals(K key1, K key2), 61 external factory HashMap({bool equals(K key1, K key2),
62 int hashCode(K key), 62 int hashCode(K key),
63 bool isValidKey(potentialKey)}); 63 bool isValidKey(potentialKey)});
64 64
65 /** 65 /**
66 * Creates an unordered identity-based map.
67 *
68 * Effectively a shorthand for:
69 *
70 * new HashMap(equals: identical, hashCode: identityHashCodeOf)
71 */
72 external factory HashMap.identity();
73
74 /**
66 * Creates a [HashMap] that contains all key value pairs of [other]. 75 * Creates a [HashMap] that contains all key value pairs of [other].
67 */ 76 */
68 factory HashMap.from(Map<K, V> other) { 77 factory HashMap.from(Map<K, V> other) {
69 return new HashMap<K, V>()..addAll(other); 78 return new HashMap<K, V>()..addAll(other);
70 } 79 }
71 80
72 /** 81 /**
73 * Creates a [HashMap] where the keys and values are computed from the 82 * Creates a [HashMap] where the keys and values are computed from the
74 * [iterable]. 83 * [iterable].
75 * 84 *
(...skipping 23 matching lines...) Expand all
99 * overwrites the previous value. 108 * overwrites the previous value.
100 * 109 *
101 * It is an error if the two [Iterable]s don't have the same length. 110 * It is an error if the two [Iterable]s don't have the same length.
102 */ 111 */
103 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { 112 factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) {
104 HashMap<K, V> map = new HashMap<K, V>(); 113 HashMap<K, V> map = new HashMap<K, V>();
105 Maps._fillMapWithIterables(map, keys, values); 114 Maps._fillMapWithIterables(map, keys, values);
106 return map; 115 return map;
107 } 116 }
108 } 117 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/collection_patch.dart ('k') | sdk/lib/collection/hash_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698