Chromium Code Reviews| Index: sdk/lib/collection/hash_map.dart |
| diff --git a/sdk/lib/collection/hash_map.dart b/sdk/lib/collection/hash_map.dart |
| index 2d08e35890696589b494681de77adc10dd5cd36c..863276a25a57659c8aa210d14c55ebf9871a5eee 100644 |
| --- a/sdk/lib/collection/hash_map.dart |
| +++ b/sdk/lib/collection/hash_map.dart |
| @@ -18,8 +18,6 @@ part of dart.collection; |
| class HashMap<K, V> implements Map<K, V> { |
| external HashMap(); |
| - static _id(x) => x; |
| - |
| factory HashMap.from(Map<K, V> other) { |
| return new HashMap<K, V>()..addAll(other); |
| } |
| @@ -27,36 +25,13 @@ class HashMap<K, V> implements Map<K, V> { |
| factory HashMap.fromIterable(Iterable iterable, |
|
floitsch
2013/06/27 16:04:32
Actually I think we need to copy the dart-doc from
zarah
2013/06/27 17:00:07
Done.
|
| {K key(element), V value(element)}) { |
| HashMap<K, V> map = new HashMap<K, V>(); |
| - |
| - if (key == null) key = _id; |
| - if (value == null) value = _id; |
| - |
| - for (var element in iterable) { |
| - map[key(element)] = value(element); |
| - } |
| - |
| + Maps._fillMapWithMappedIterable(map, iterable, key: key, value: value); |
| return map; |
| } |
| factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) { |
| HashMap<K, V> map = new HashMap<K, V>(); |
| - |
| - Iterator<K> keyIterator = keys.iterator; |
| - Iterator<V> valueIterator = values.iterator; |
| - |
| - bool hasNextKey = keyIterator.moveNext(); |
| - bool hasNextValue = valueIterator.moveNext(); |
| - |
| - while (hasNextKey && hasNextValue) { |
| - map[keyIterator.current] = valueIterator.current; |
| - hasNextKey = keyIterator.moveNext(); |
| - hasNextValue = valueIterator.moveNext(); |
| - } |
| - |
| - if (hasNextKey || hasNextValue) { |
| - throw new ArgumentError("Iterables do not have same length."); |
| - } |
| - |
| + Maps._fillMapWithIterables(map, keys, values); |
| return map; |
| } |