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

Unified Diff: sdk/lib/core/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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/map.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/set.dart
diff --git a/sdk/lib/core/set.dart b/sdk/lib/core/set.dart
index bd6aded52d97a053b2f7e676f282564fe48c207e..19be402b71fe579abfc4191ea6faa4d3299dfaba 100644
--- a/sdk/lib/core/set.dart
+++ b/sdk/lib/core/set.dart
@@ -8,7 +8,7 @@ part of dart.core;
* A collection of objects in which each object can occur only once.
*
* That is, for each object of the element type, the object is either considered
- * to be in the set, or to _not_ be in the set.
+ * to be in the set, or to _not_ be in the set.
*
* Set implementations may consider some elements indistinguishable. These
* elements are treated as being the same for any operation on the set.
@@ -24,11 +24,19 @@ abstract class Set<E> extends IterableBase<E> {
/**
* Creates an empty [Set].
*
- * The created `Set` is a [HashSet]. As such, it considers elements that
- * are equal (using `==`) to be undistinguishable, and requires them to
+ * The created `Set` is a [LinkedHashSet]. As such, it considers elements that
+ * are equal (using `==`) to be indistinguishable, and requires them to
* have a compatible [Object.hashCode] implementation.
*/
- factory Set() => new HashSet<E>();
+ factory Set() = LinkedHashSet<E>;
+
+ /**
+ * Creates an empty identity [Set].
+ *
+ * The created `Set` is a [LinkedHashSet] that uses identity as equality
+ * relation.
+ */
+ factory Set.identity() = LinkedHashSet<E>.identity;
/**
* Creates a [Set] that contains all elements of [other].
@@ -37,7 +45,7 @@ abstract class Set<E> extends IterableBase<E> {
* are equal (using `==`) to be undistinguishable, and requires them to
* have a compatible [Object.hashCode] implementation.
*/
- factory Set.from(Iterable<E> other) => new HashSet<E>.from(other);
+ factory Set.from(Iterable<E> other) = LinkedHashSet<E>.from;
/**
* Returns true if [value] is in the set.
« no previous file with comments | « sdk/lib/core/map.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698