| 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 /** | 5 /** |
| 6 * A [Map] is an associative container, mapping a key to a value. | 6 * A [Map] is an associative container, mapping a key to a value. |
| 7 * Null values are supported, but null keys are not. | 7 * Null values are supported, but null keys are not. |
| 8 */ | 8 */ |
| 9 abstract class Map<K, V> { | 9 abstract class Map<K, V> { |
| 10 /** | 10 /** |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 * Removes all pairs from the map. | 60 * Removes all pairs from the map. |
| 61 */ | 61 */ |
| 62 void clear(); | 62 void clear(); |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Applies [f] to each {key, value} pair of the map. | 65 * Applies [f] to each {key, value} pair of the map. |
| 66 */ | 66 */ |
| 67 void forEach(void f(K key, V value)); | 67 void forEach(void f(K key, V value)); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Returns a collection containing all the keys in the map. | 70 * Returns a [Queryable] iterating over all the keys in the map. |
| 71 * |
| 72 * The iteration-order is guaranteed to be the same for [keys] and [values]. |
| 73 * That is, [values] is equivalent to [:keys.mappedBy((key) => this[key]):]; |
| 71 */ | 74 */ |
| 72 Collection<K> get keys; | 75 Queryable<K> get keys; |
| 73 | 76 |
| 74 /** | 77 /** |
| 75 * Returns a collection containing all the values in the map. | 78 * Returns a [Queryable] iterating over all the value of the map. |
| 79 * |
| 80 * The iteration-order is guaranteed to be the same for [keys] and [values]. |
| 81 * That is, [values] is equivalent to [:keys.mappedBy((key) => this[key]):]; |
| 76 */ | 82 */ |
| 77 Collection<V> get values; | 83 Queryable<V> get values; |
| 78 | 84 |
| 79 /** | 85 /** |
| 80 * The number of {key, value} pairs in the map. | 86 * The number of {key, value} pairs in the map. |
| 81 */ | 87 */ |
| 82 int get length; | 88 int get length; |
| 83 | 89 |
| 84 /** | 90 /** |
| 85 * Returns true if there is no {key, value} pair in the map. | 91 * Returns true if there is no {key, value} pair in the map. |
| 86 */ | 92 */ |
| 87 bool get isEmpty; | 93 bool get isEmpty; |
| 94 |
| 95 /** |
| 96 * Returns a read-only view of [this]. |
| 97 * |
| 98 * The returned [Map] is backed by [this] but cannot change [this]. |
| 99 */ |
| 100 Map<K, V> get view; |
| 88 } | 101 } |
| 89 | 102 |
| 90 /** | 103 /** |
| 91 * Hash map version of the [Map] interface. A [HashMap] does not | 104 * Hash map version of the [Map] interface. A [HashMap] does not |
| 92 * provide any guarantees on the order of keys and values in [keys] | 105 * provide any guarantees on the order of keys and values in [keys] |
| 93 * and [values]. | 106 * and [values]. |
| 94 */ | 107 */ |
| 95 abstract class HashMap<K, V> extends Map<K, V> { | 108 abstract class HashMap<K, V> extends Map<K, V> { |
| 96 /** | 109 /** |
| 97 * Creates a map with the default implementation. | 110 * Creates a map with the default implementation. |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 530 |
| 518 void clear() { | 531 void clear() { |
| 519 _map.clear(); | 532 _map.clear(); |
| 520 _list.clear(); | 533 _list.clear(); |
| 521 } | 534 } |
| 522 | 535 |
| 523 String toString() { | 536 String toString() { |
| 524 return Maps.mapToString(this); | 537 return Maps.mapToString(this); |
| 525 } | 538 } |
| 526 } | 539 } |
| OLD | NEW |