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

Unified Diff: sdk/lib/core/set.dart

Issue 26681002: Add EfficientLength marker interface to some iterabels. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also document Map.length is efficient, while we are at it. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/map.dart ('k') | sdk/lib/utf/utf.dart » ('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 19be402b71fe579abfc4191ea6faa4d3299dfaba..998fe98261a3356ddb3ff14d62a46414b9052247 100644
--- a/sdk/lib/core/set.dart
+++ b/sdk/lib/core/set.dart
@@ -20,7 +20,7 @@ part of dart.core;
* guarantee anything about the order that elements are accessed in by
* iteration. [LinkedHashSet] iterates in the insertion order of its elements.
*/
-abstract class Set<E> extends IterableBase<E> {
+abstract class Set<E> extends IterableBase<E> implements EfficientLength {
/**
* Creates an empty [Set].
*
@@ -48,6 +48,14 @@ abstract class Set<E> extends IterableBase<E> {
factory Set.from(Iterable<E> other) = LinkedHashSet<E>.from;
/**
+ * Returns the number of elements in this set.
+ *
+ * This operation is efficient, and does not require iterating and counting
+ * the elements.
+ */
+ int get length;
+
+ /**
* Returns true if [value] is in the set.
*/
bool contains(Object value);
« no previous file with comments | « sdk/lib/core/map.dart ('k') | sdk/lib/utf/utf.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698