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

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

Issue 16406005: Add addAll to Map interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | sdk/lib/core/map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/splay_tree.dart
diff --git a/sdk/lib/collection/splay_tree.dart b/sdk/lib/collection/splay_tree.dart
index b959a55721e843a263c34c0816c8bc0bb55a17d7..20cc84cd168512b1538cc332a1638c3e739862c7 100644
--- a/sdk/lib/collection/splay_tree.dart
+++ b/sdk/lib/collection/splay_tree.dart
@@ -248,6 +248,9 @@ class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> {
SplayTreeMap([int compare(K key1, K key2)])
: _comparator = (compare == null) ? Comparable.compare : compare;
+ factory SplayTreeMap.from(Map<K, V> other, [int compare(K key1, K key2)]) =>
+ new SplayTreeMap(compare)..addAll(other);
+
int _compare(K key1, K key2) => _comparator(key1, key2);
SplayTreeMap._internal();
@@ -307,9 +310,11 @@ class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> {
return value;
}
+ void addAll(Map<K, V> other) {
+ other.forEach((K key, V value) { this[key] = value; });
+ }
+
bool get isEmpty {
- // assert(!((_root == null) && (_count != 0)));
- // assert(!((_count == 0) && (_root != null)));
return (_root == null);
}
« no previous file with comments | « no previous file | sdk/lib/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698