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

Side by Side Diff: sdk/lib/collection/linked_hash_set.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/collection/linked_hash_map.dart ('k') | sdk/lib/core/map.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 /** 7 /**
8 * A [LinkedHashSet] is a hash-table based [Set] implementation. 8 * A [LinkedHashSet] is a hash-table based [Set] implementation.
9 * 9 *
10 * The `LinkedHashSet` also keep track of the order that elements were inserted 10 * The `LinkedHashSet` also keep track of the order that elements were inserted
11 * in, and iteration happens in first-to-last insertion order. 11 * in, and iteration happens in first-to-last insertion order.
12 * 12 *
13 * The elements of a `LinkedHashSet` must have consistent [Object.operator==] 13 * The elements of a `LinkedHashSet` must have consistent [Object.operator==]
14 * and [Object.hashCode] implementations. This means that the `==` operator 14 * and [Object.hashCode] implementations. This means that the `==` operator
15 * must define a stable equivalence relation on the elements (reflexive, 15 * must define a stable equivalence relation on the elements (reflexive,
16 * anti-symmetric, transitive, and consistent over time), and that `hashCode` 16 * anti-symmetric, transitive, and consistent over time), and that `hashCode`
17 * must be the same for objects that are considered equal by `==`. 17 * must be the same for objects that are considered equal by `==`.
18 * 18 *
19 * The set allows `null` as an element. 19 * The set allows `null` as an element.
20 * 20 *
21 * Most simple operations on `HashSet` are done in constant time: [add], 21 * Most simple operations on `HashSet` are done in constant time: [add],
22 * [contains], [remove], and [length]. 22 * [contains], [remove], and [length].
23 */ 23 */
24 class LinkedHashSet<E> implements HashSet<E> { 24 class LinkedHashSet<E> implements HashSet<E> {
25 25
26 external factory LinkedHashSet({ bool equals(E e1, E e2), 26 external factory LinkedHashSet({ bool equals(E e1, E e2),
27 int hashCode(E e), 27 int hashCode(E e),
28 bool isValidKey(potentialKey) }); 28 bool isValidKey(potentialKey) });
29 29
30 /**
31 * Creates an insertion-ordered identity-based set.
32 *
33 * Effectively a shorthand for:
34 *
35 * new LinkedHashSet(equals: identical, hashCode: identityHashCodeOf)
36 */
37 external factory LinkedHashSet.identity();
38
39
30 factory LinkedHashSet.from(Iterable<E> iterable) { 40 factory LinkedHashSet.from(Iterable<E> iterable) {
31 return new LinkedHashSet<E>()..addAll(iterable); 41 return new LinkedHashSet<E>()..addAll(iterable);
32 } 42 }
33 } 43 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/linked_hash_map.dart ('k') | sdk/lib/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698