| 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 /** | 7 /** |
| 8 * A hash-table based implementation of [Map]. | 8 * A hash-table based implementation of [Map]. |
| 9 * | 9 * |
| 10 * Keys insertion order is remembered, and keys are iterated in insertion order. | 10 * Keys insertion order is remembered, and keys are iterated in insertion order. |
| 11 * Values are iterated in their corresponding key's order. | 11 * Values are iterated in their corresponding key's order. |
| 12 * | 12 * |
| 13 * The keys of a `HashMap` must have consistent [Object.operator==] | 13 * The keys of a `HashMap` must have consistent [Object.operator==] |
| 14 * and [Object.hashCode] implementations. This means that the `==` operator | 14 * and [Object.hashCode] implementations. This means that the `==` operator |
| 15 * must define a stable equivalence relation on the keys (reflexive, | 15 * must define a stable equivalence relation on the keys (reflexive, |
| 16 * anti-symmetric, transitive, and consistent over time), and that `hashCode` | 16 * anti-symmetric, transitive, and consistent over time), and that `hashCode` |
| 17 * must be the same for objects that are considered equal by `==`. | 17 * must be the same for objects that are considered equal by `==`. |
| 18 * | 18 * |
| 19 * The map allows `null` as a key. | 19 * The map allows `null` as a key. |
| 20 */ | 20 */ |
| 21 class LinkedHashMap<K, V> implements Map<K, V> { | 21 class LinkedHashMap<K, V> implements Map<K, V> { |
| 22 external LinkedHashMap(); | 22 external LinkedHashMap(); |
| 23 | 23 |
| 24 factory LinkedHashMap.from(Map<K, V> other) { | 24 factory LinkedHashMap.from(Map<K, V> other) { |
| 25 return new LinkedHashMap<K, V>()..addAll(other); | 25 return new LinkedHashMap<K, V>()..addAll(other); |
| 26 } | 26 } |
| 27 | 27 |
| 28 external bool containsKey(K key); | 28 external bool containsKey(Object key); |
| 29 | 29 |
| 30 external bool containsValue(V value); | 30 external bool containsValue(Object value); |
| 31 | 31 |
| 32 external void addAll(Map<K, V> other); | 32 external void addAll(Map<K, V> other); |
| 33 | 33 |
| 34 external V operator [](K key); | 34 external V operator [](Object key); |
| 35 | 35 |
| 36 external void operator []=(K key, V value); | 36 external void operator []=(K key, V value); |
| 37 | 37 |
| 38 external V putIfAbsent(K key, V ifAbsent()); | 38 external V putIfAbsent(K key, V ifAbsent()); |
| 39 | 39 |
| 40 external V remove(K key); | 40 external V remove(Object key); |
| 41 | 41 |
| 42 external void clear(); | 42 external void clear(); |
| 43 | 43 |
| 44 external void forEach(void action (K key, V value)); | 44 external void forEach(void action (K key, V value)); |
| 45 | 45 |
| 46 /** The keys of the map, in insertion order. */ | 46 /** The keys of the map, in insertion order. */ |
| 47 external Iterable<K> get keys; | 47 external Iterable<K> get keys; |
| 48 /** The values of the map, in the order of their corresponding [keys].*/ | 48 /** The values of the map, in the order of their corresponding [keys].*/ |
| 49 external Iterable<V> get values; | 49 external Iterable<V> get values; |
| 50 | 50 |
| 51 external int get length; | 51 external int get length; |
| 52 | 52 |
| 53 external bool get isEmpty; | 53 external bool get isEmpty; |
| 54 | 54 |
| 55 external bool get isNotEmpty; | 55 external bool get isNotEmpty; |
| 56 | 56 |
| 57 String toString() => Maps.mapToString(this); | 57 String toString() => Maps.mapToString(this); |
| 58 } | 58 } |
| OLD | NEW |