OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, 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 library yaml.map; | |
6 | |
7 import 'dart:collection'; | |
8 | |
9 import 'package:collection/collection.dart'; | |
10 | |
11 import 'deep_equals.dart'; | |
12 import 'utils.dart'; | |
13 | |
14 /// This class behaves almost identically to the normal Dart [Map] | |
15 /// implementation, with the following differences: | |
16 /// | |
17 /// * It allows NaN, list, and map keys. | |
18 /// * It defines `==` structurally. That is, `yamlMap1 == yamlMap2` if they | |
19 /// have the same contents. | |
20 /// * It has a compatible [hashCode] method. | |
21 /// | |
22 /// This class is deprecated. In future releases, this package will use | |
23 /// a [HashMap] with a custom equality operation rather than a custom class. | |
24 @Deprecated('1.0.0') | |
25 class YamlMap extends DelegatingMap { | |
26 YamlMap() | |
27 : super(new HashMap(equals: deepEquals, hashCode: hashCodeFor)); | |
28 | |
29 YamlMap.from(Map map) | |
30 : super(new HashMap(equals: deepEquals, hashCode: hashCodeFor)) { | |
31 addAll(map); | |
32 } | |
33 | |
34 int get hashCode => hashCodeFor(this); | |
35 | |
36 bool operator ==(other) { | |
37 if (other is! YamlMap) return false; | |
38 return deepEquals(this, other); | |
39 } | |
40 } | |
OLD | NEW |