OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:collection'; |
| 6 |
| 7 import 'equality.dart'; |
| 8 import 'wrappers.dart'; |
| 9 |
| 10 /// A [Map] whose key equality is determined by an [Equality] object. |
| 11 class EqualityMap<K, V> extends DelegatingMap<K, V> { |
| 12 /// Creates a map with equality based on [equality]. |
| 13 EqualityMap(Equality<K> equality) |
| 14 : super(new LinkedHashMap( |
| 15 equals: equality.equals, |
| 16 hashCode: equality.hash, |
| 17 isValidKey: equality.isValidKey)); |
| 18 |
| 19 /// Creates a map with equality based on [equality] that contains all |
| 20 /// key-value pairs of [other]. |
| 21 /// |
| 22 /// If [other] has multiple keys that are equivalent according to [equality], |
| 23 /// the last one reached during iteration takes precedence. |
| 24 EqualityMap.from(Equality<K> equality, Map<K, V> other) |
| 25 : super(new LinkedHashMap( |
| 26 equals: equality.equals, |
| 27 hashCode: equality.hash, |
| 28 isValidKey: equality.isValidKey)) { |
| 29 addAll(other); |
| 30 } |
| 31 } |
OLD | NEW |