Chromium Code Reviews| 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]. | |
| 38 * | |
| 39 * For each element of the [iterable] this constructor computes a key/value pa ir, | |
|
floitsch
2013/06/27 13:07:17
long lines.
zarah
2013/06/27 13:13:13
Done.
| |
| 40 * by applying [key] and [value] respectively. | |
| 41 * | |
| 42 * The keys of the key/value pairs do not need to be unique. The last occurren ce of | |
|
floitsch
2013/06/27 13:07:17
long line.
zarah
2013/06/27 13:13:13
Done.
| |
| 43 * a key will simply overwrite any previous value. | |
| 44 * | |
| 45 * If no values are specified for [key] and [value] the default is the | |
| 46 * identity function. | |
| 47 */ | |
| 48 factory Map.fromIterable(Iterable iterable, | |
| 49 {K key(element), V value(element)}) = HashMap<K, V>.fromIterable; | |
| 50 | |
| 51 /** | |
| 23 * Returns whether this map contains the given [value]. | 52 * Returns whether this map contains the given [value]. |
| 24 */ | 53 */ |
| 25 bool containsValue(Object value); | 54 bool containsValue(Object value); |
| 26 | 55 |
| 27 /** | 56 /** |
| 28 * Returns whether this map contains the given [key]. | 57 * Returns whether this map contains the given [key]. |
| 29 */ | 58 */ |
| 30 bool containsKey(Object key); | 59 bool containsKey(Object key); |
| 31 | 60 |
| 32 /** | 61 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 /** | 130 /** |
| 102 * 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. |
| 103 */ | 132 */ |
| 104 bool get isEmpty; | 133 bool get isEmpty; |
| 105 | 134 |
| 106 /** | 135 /** |
| 107 * 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. |
| 108 */ | 137 */ |
| 109 bool get isNotEmpty; | 138 bool get isNotEmpty; |
| 110 } | 139 } |
| OLD | NEW |