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]. |
50 */ | 53 */ |
51 V putIfAbsent(K key, V ifAbsent()); | 54 V putIfAbsent(K key, V ifAbsent()); |
52 | 55 |
53 /** | 56 /** |
54 * Removes the association for the given [key]. Returns the value for | 57 * Removes the association for the given [key]. Returns the value for |
55 * [key] in the map or null if [key] is not in the map. Note that values | 58 * [key] in the map or null if [key] is not in the map. Note that values |
56 * can be null and a returned null value does not always imply that the | 59 * can be null and a returned null value does not always imply that the |
57 * key is absent. | 60 * key is absent. |
58 */ | 61 */ |
59 V remove(K key); | 62 V remove(K key); |
60 | 63 |
61 /** | 64 /** |
62 * Removes all pairs from the map. | 65 * Removes all pairs from the map. |
63 */ | 66 */ |
64 void clear(); | 67 void clear(); |
65 | 68 |
66 /** | 69 /** |
67 * Applies [f] to each {key, value} pair of the map. | 70 * 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. |
68 */ | 73 */ |
69 void forEach(void f(K key, V value)); | 74 void forEach(void f(K key, V value)); |
70 | 75 |
71 /** | 76 /** |
72 * The keys of [this]. | 77 * The keys of [this]. |
73 */ | 78 */ |
74 // TODO(floitsch): this should return a [Set]. | 79 // TODO(floitsch): this should return a [Set]. |
75 Iterable<K> get keys; | 80 Iterable<K> get keys; |
76 | 81 |
77 /** | 82 /** |
78 * The values of [this]. | 83 * The values of [this]. |
79 */ | 84 */ |
80 Iterable<V> get values; | 85 Iterable<V> get values; |
81 | 86 |
82 /** | 87 /** |
83 * The number of {key, value} pairs in the map. | 88 * The number of {key, value} pairs in the map. |
84 */ | 89 */ |
85 int get length; | 90 int get length; |
86 | 91 |
87 /** | 92 /** |
88 * Returns true if there is no {key, value} pair in the map. | 93 * Returns true if there is no {key, value} pair in the map. |
89 */ | 94 */ |
90 bool get isEmpty; | 95 bool get isEmpty; |
91 } | 96 } |
OLD | NEW |