OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 library yaml_map; | 5 library yaml_map; |
6 | 6 |
7 import 'deep_equals.dart'; | 7 import 'deep_equals.dart'; |
8 import 'utils.dart'; | 8 import 'utils.dart'; |
9 | 9 |
10 /// This class wraps behaves almost identically to the normal Dart Map | 10 /// This class wraps behaves almost identically to the normal Dart Map |
(...skipping 18 matching lines...) Expand all Loading... |
29 operator []=(key, value) { _map[_wrapKey(key)] = value; } | 29 operator []=(key, value) { _map[_wrapKey(key)] = value; } |
30 putIfAbsent(key, ifAbsent()) => _map.putIfAbsent(_wrapKey(key), ifAbsent); | 30 putIfAbsent(key, ifAbsent()) => _map.putIfAbsent(_wrapKey(key), ifAbsent); |
31 remove(key) => _map.remove(_wrapKey(key)); | 31 remove(key) => _map.remove(_wrapKey(key)); |
32 void clear() => _map.clear(); | 32 void clear() => _map.clear(); |
33 void forEach(void f(key, value)) => | 33 void forEach(void f(key, value)) => |
34 _map.forEach((k, v) => f(_unwrapKey(k), v)); | 34 _map.forEach((k, v) => f(_unwrapKey(k), v)); |
35 Iterable get keys => _map.keys.map(_unwrapKey); | 35 Iterable get keys => _map.keys.map(_unwrapKey); |
36 Iterable get values => _map.values; | 36 Iterable get values => _map.values; |
37 int get length => _map.length; | 37 int get length => _map.length; |
38 bool get isEmpty => _map.isEmpty; | 38 bool get isEmpty => _map.isEmpty; |
| 39 bool get isNotEmpty => map.isNotEmpty; |
39 String toString() => _map.toString(); | 40 String toString() => _map.toString(); |
40 | 41 |
41 int get hashCode => hashCodeFor(_map); | 42 int get hashCode => hashCodeFor(_map); |
42 | 43 |
43 bool operator ==(other) { | 44 bool operator ==(other) { |
44 if (other is! YamlMap) return false; | 45 if (other is! YamlMap) return false; |
45 return deepEquals(this, other); | 46 return deepEquals(this, other); |
46 } | 47 } |
47 | 48 |
48 /// Wraps an object for use as a key in the map. | 49 /// Wraps an object for use as a key in the map. |
(...skipping 22 matching lines...) Expand all Loading... |
71 int get hashCode => hashCodeFor(value); | 72 int get hashCode => hashCodeFor(value); |
72 | 73 |
73 String toString() => value.toString(); | 74 String toString() => value.toString(); |
74 | 75 |
75 /// This is defined as both values being structurally equal. | 76 /// This is defined as both values being structurally equal. |
76 bool operator ==(other) { | 77 bool operator ==(other) { |
77 if (other is! _WrappedHashKey) return false; | 78 if (other is! _WrappedHashKey) return false; |
78 return deepEquals(this.value, other.value); | 79 return deepEquals(this.value, other.value); |
79 } | 80 } |
80 } | 81 } |
OLD | NEW |