| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A hash-table based implementation of [Map]. | 8 * A hash-table based implementation of [Map]. |
| 9 * | 9 * |
| 10 * The keys of a `HashMap` must have consistent [Object.operator==] | 10 * The keys of a `HashMap` must have consistent [Object.operator==] |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 * | 31 * |
| 32 * For each element of the [iterable] this constructor computes a key/value | 32 * For each element of the [iterable] this constructor computes a key/value |
| 33 * pair, by applying [key] and [value] respectively. | 33 * pair, by applying [key] and [value] respectively. |
| 34 * | 34 * |
| 35 * The keys of the key/value pairs do not need to be unique. The last | 35 * The keys of the key/value pairs do not need to be unique. The last |
| 36 * occurrence of a key will simply overwrite any previous value. | 36 * occurrence of a key will simply overwrite any previous value. |
| 37 * | 37 * |
| 38 * If no values are specified for [key] and [value] the default is the | 38 * If no values are specified for [key] and [value] the default is the |
| 39 * identity function. | 39 * identity function. |
| 40 */ | 40 */ |
| 41 factory HashMap.fromIterable(Iterable<K> iterable, | 41 factory HashMap.fromIterable(Iterable iterable, |
| 42 {K key(element), V value(element)}) { | 42 {K key(element), V value(element)}) { |
| 43 HashMap<K, V> map = new HashMap<K, V>(); | 43 HashMap<K, V> map = new HashMap<K, V>(); |
| 44 Maps._fillMapWithMappedIterable(map, iterable, key, value); | 44 Maps._fillMapWithMappedIterable(map, iterable, key, value); |
| 45 return map; | 45 return map; |
| 46 } | 46 } |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Creates a [HashMap] associating the given [keys] to [values]. | 49 * Creates a [HashMap] associating the given [keys] to [values]. |
| 50 * | 50 * |
| 51 * This constructor iterates over [keys] and [values] and maps each element of | 51 * This constructor iterates over [keys] and [values] and maps each element of |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 | 79 |
| 80 external V putIfAbsent(K key, V ifAbsent()); | 80 external V putIfAbsent(K key, V ifAbsent()); |
| 81 | 81 |
| 82 external V remove(Object key); | 82 external V remove(Object key); |
| 83 external void clear(); | 83 external void clear(); |
| 84 | 84 |
| 85 external void forEach(void action(K key, V value)); | 85 external void forEach(void action(K key, V value)); |
| 86 | 86 |
| 87 String toString() => Maps.mapToString(this); | 87 String toString() => Maps.mapToString(this); |
| 88 } | 88 } |
| OLD | NEW |