| 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 */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Associates the [key] with the given [value]. | 42 * Associates the [key] with the given [value]. |
| 43 */ | 43 */ |
| 44 void operator []=(K key, V value); | 44 void operator []=(K key, V value); |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * If [key] is not associated to a value, calls [ifAbsent] and | 47 * If [key] is not associated to a value, calls [ifAbsent] and |
| 48 * updates the map by mapping [key] to the value returned by | 48 * updates the map by mapping [key] to the value returned by |
| 49 * [ifAbsent]. Returns the value in the map. | 49 * [ifAbsent]. Returns the value in the map. |
| 50 * | |
| 51 * It is an error to add or remove keys from map during the call to | |
| 52 * [ifAbsent]. | |
| 53 */ | 50 */ |
| 54 V putIfAbsent(K key, V ifAbsent()); | 51 V putIfAbsent(K key, V ifAbsent()); |
| 55 | 52 |
| 56 /** | 53 /** |
| 57 * Removes the association for the given [key]. Returns the value for | 54 * Removes the association for the given [key]. Returns the value for |
| 58 * [key] in the map or null if [key] is not in the map. Note that values | 55 * [key] in the map or null if [key] is not in the map. Note that values |
| 59 * can be null and a returned null value does not always imply that the | 56 * can be null and a returned null value does not always imply that the |
| 60 * key is absent. | 57 * key is absent. |
| 61 */ | 58 */ |
| 62 V remove(K key); | 59 V remove(K key); |
| 63 | 60 |
| 64 /** | 61 /** |
| 65 * Removes all pairs from the map. | 62 * Removes all pairs from the map. |
| 66 */ | 63 */ |
| 67 void clear(); | 64 void clear(); |
| 68 | 65 |
| 69 /** | 66 /** |
| 70 * Applies [f] to each {key, value} pair of the map. | 67 * Applies [f] to each {key, value} pair of the map. |
| 71 * | |
| 72 * It is an error to add or remove keys from the map during iteration. | |
| 73 */ | 68 */ |
| 74 void forEach(void f(K key, V value)); | 69 void forEach(void f(K key, V value)); |
| 75 | 70 |
| 76 /** | 71 /** |
| 77 * The keys of [this]. | 72 * The keys of [this]. |
| 78 */ | 73 */ |
| 79 // TODO(floitsch): this should return a [Set]. | 74 // TODO(floitsch): this should return a [Set]. |
| 80 Iterable<K> get keys; | 75 Iterable<K> get keys; |
| 81 | 76 |
| 82 /** | 77 /** |
| 83 * The values of [this]. | 78 * The values of [this]. |
| 84 */ | 79 */ |
| 85 Iterable<V> get values; | 80 Iterable<V> get values; |
| 86 | 81 |
| 87 /** | 82 /** |
| 88 * The number of {key, value} pairs in the map. | 83 * The number of {key, value} pairs in the map. |
| 89 */ | 84 */ |
| 90 int get length; | 85 int get length; |
| 91 | 86 |
| 92 /** | 87 /** |
| 93 * Returns true if there is no {key, value} pair in the map. | 88 * Returns true if there is no {key, value} pair in the map. |
| 94 */ | 89 */ |
| 95 bool get isEmpty; | 90 bool get isEmpty; |
| 96 } | 91 } |
| OLD | NEW |