| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A [Map] is an associative container, mapping a key to a value. | 8 * A [Map] is an associative container, mapping a key to a value. |
| 9 * Null values are supported, but null keys are not. | 9 * Null values are supported, but null keys are not. |
| 10 */ | 10 */ |
| 11 abstract class Map<K, V> { | 11 abstract class Map<K, V> { |
| 12 /** | 12 /** |
| 13 * Creates a map with the default implementation. | 13 * Creates a map with the default implementation. |
| 14 */ | 14 */ |
| 15 factory Map() => new HashMap<K, V>(); | 15 factory Map() => new HashMap<K, V>(); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Creates a [Map] that contains all key value pairs of [other]. | 18 * Creates a [Map] that contains all key value pairs of [other]. |
| 19 */ | 19 */ |
| 20 factory Map.from(Map<K, V> other) => new HashMap<K, V>.from(other); | 20 factory Map.from(Map<K, V> other) => new HashMap<K, V>.from(other); |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Creates a [Map] associating the given [keys] to [values]. | |
| 24 * | |
| 25 * This constructor iterates over [keys] and [values] and maps each element of | |
| 26 * [keys] to the corresponding element of [values]. | |
| 27 * | |
| 28 * If [keys] contains the same object multiple times, the last occurrence | |
| 29 * overwrites the previous value. | |
| 30 * | |
| 31 * It is an error if the two [Iterable]s don't have the same length. | |
| 32 */ | |
| 33 factory Map.fromIterables(Iterable<K> keys, Iterable<V> values) | |
| 34 = HashMap<K, V>.fromIterables; | |
| 35 | |
| 36 /** | |
| 37 * Creates a [Map] where the keys and values are computed from the [iterable]. | 23 * Creates a [Map] where the keys and values are computed from the [iterable]. |
| 38 * | 24 * |
| 39 * For each element of the [iterable] this constructor computes a key/value | 25 * For each element of the [iterable] this constructor computes a key/value |
| 40 * pair, by applying [key] and [value] respectively. | 26 * pair, by applying [key] and [value] respectively. |
| 41 * | 27 * |
| 42 * The keys of the key/value pairs do not need to be unique. The last | 28 * The keys of the key/value pairs do not need to be unique. The last |
| 43 * occurrence of a key will simply overwrite any previous value. | 29 * occurrence of a key will simply overwrite any previous value. |
| 44 * | 30 * |
| 45 * If no values are specified for [key] and [value] the default is the | 31 * If no values are specified for [key] and [value] the default is the |
| 46 * identity function. | 32 * identity function. |
| 47 */ | 33 */ |
| 48 factory Map.fromIterable(Iterable iterable, | 34 factory Map.fromIterable(Iterable<K> iterable, |
| 49 {K key(element), V value(element)}) = HashMap<K, V>.fromIterable; | 35 {K key(element), V value(element)}) = HashMap<K, V>.fromIterable; |
| 50 | 36 |
| 51 /** | 37 /** |
| 38 * Creates a [Map] associating the given [keys] to [values]. |
| 39 * |
| 40 * This constructor iterates over [keys] and [values] and maps each element of |
| 41 * [keys] to the corresponding element of [values]. |
| 42 * |
| 43 * If [keys] contains the same object multiple times, the last occurrence |
| 44 * overwrites the previous value. |
| 45 * |
| 46 * It is an error if the two [Iterable]s don't have the same length. |
| 47 */ |
| 48 factory Map.fromIterables(Iterable<K> keys, Iterable<V> values) |
| 49 = HashMap<K, V>.fromIterables; |
| 50 |
| 51 /** |
| 52 * Returns whether this map contains the given [value]. | 52 * Returns whether this map contains the given [value]. |
| 53 */ | 53 */ |
| 54 bool containsValue(Object value); | 54 bool containsValue(Object value); |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Returns whether this map contains the given [key]. | 57 * Returns whether this map contains the given [key]. |
| 58 */ | 58 */ |
| 59 bool containsKey(Object key); | 59 bool containsKey(Object key); |
| 60 | 60 |
| 61 /** | 61 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 /** | 130 /** |
| 131 * Returns true if there is no {key, value} pair in the map. | 131 * Returns true if there is no {key, value} pair in the map. |
| 132 */ | 132 */ |
| 133 bool get isEmpty; | 133 bool get isEmpty; |
| 134 | 134 |
| 135 /** | 135 /** |
| 136 * Returns true if there is at least one {key, value} pair in the map. | 136 * Returns true if there is at least one {key, value} pair in the map. |
| 137 */ | 137 */ |
| 138 bool get isNotEmpty; | 138 bool get isNotEmpty; |
| 139 } | 139 } |
| OLD | NEW |