Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | |
| 8 * A hash-table based implementation of [Map]. | |
| 9 * | |
| 10 * The keys of a `HashMap` must have consistent [Object.operator==] | |
| 11 * and [Object.hashCode] implementations. This means that the `==` operator | |
| 12 * must define a stable equivalence relation on the keys (reflexive, | |
| 13 * anti-symmetric, trasnitive, and consistent over time), and that `hashCode` | |
|
floitsch
2013/06/06 14:00:53
transitive
Lasse Reichstein Nielsen
2013/06/10 05:48:50
But I changed that! Really!
Grumble!
| |
| 14 * must be the same for objects that are considered equal by `==`. | |
| 15 * | |
| 16 * The map allows `null` as a key. | |
|
floitsch
2013/06/06 14:00:53
Should we add that the equivalence relationship do
Lasse Reichstein Nielsen
2013/06/10 05:48:50
That is a property of doubles, which should be not
| |
| 17 */ | |
| 7 class HashMap<K, V> implements Map<K, V> { | 18 class HashMap<K, V> implements Map<K, V> { |
| 8 external HashMap(); | 19 external HashMap(); |
| 9 | 20 |
| 10 factory HashMap.from(Map<K, V> other) { | 21 factory HashMap.from(Map<K, V> other) { |
| 11 return new HashMap<K, V>()..addAll(other); | 22 return new HashMap<K, V>()..addAll(other); |
| 12 } | 23 } |
| 13 | 24 |
| 14 external int get length; | 25 external int get length; |
| 15 external bool get isEmpty; | 26 external bool get isEmpty; |
| 16 external bool get isNotEmpty; | 27 external bool get isNotEmpty; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 28 | 39 |
| 29 external V putIfAbsent(K key, V ifAbsent()); | 40 external V putIfAbsent(K key, V ifAbsent()); |
| 30 | 41 |
| 31 external V remove(K key); | 42 external V remove(K key); |
| 32 external void clear(); | 43 external void clear(); |
| 33 | 44 |
| 34 external void forEach(void action(K key, V value)); | 45 external void forEach(void action(K key, V value)); |
| 35 | 46 |
| 36 String toString() => Maps.mapToString(this); | 47 String toString() => Maps.mapToString(this); |
| 37 } | 48 } |
| OLD | NEW |