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

Unified Diff: sdk/lib/collection/maps.dart

Issue 253023004: Add MapMixin to dart:collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | « no previous file | tests/corelib/map_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/maps.dart
diff --git a/sdk/lib/collection/maps.dart b/sdk/lib/collection/maps.dart
index ef937b35548681406110bc609b19e0c7514e5a0f..1e4214fd2cbbc3e0fada8f32b7e2ca0ec8f981cc 100644
--- a/sdk/lib/collection/maps.dart
+++ b/sdk/lib/collection/maps.dart
@@ -20,9 +20,26 @@ part of dart.collection;
* A more efficient implementation is usually possible by overriding
* some of the other members as well.
*/
-abstract class MapBase<K, V> implements Map<K, V> {
- MapBase(); // Prevents use as mixin.
+abstract class MapBase<K, V> = Object with MapMixin<K, V>;
+
+/**
+ * Mixin implementing a [Map].
+ *
+ * This mixin has a basic implementation of all but five of the members of
+ * [Map].
+ * A basic `Map` class can be implemented by mixin in this class and
kevmoo 2014/04/29 13:41:11 include a blank line after the first sentence.
+ * implementing `keys`, `operator[]`, `operator[]=`, `remove` and `clear`.
+ * The remaining operations are implemented in terms of these five.
+ *
+ * The `keys` iterable should have efficient [length] and [contains]
+ * operations, and it should catch concurrent modifications of the keys
+ * while iterating.
+ *
+ * A more efficient implementation is usually possible by overriding
+ * some of the other members as well.
+ */
+abstract class MapMixin<K, V> implements Map<K, V> {
Iterable<K> get keys;
V operator[](Object key);
operator []=(K key, V value);
« no previous file with comments | « no previous file | tests/corelib/map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698