LCOV - code coverage report

Current view
top level - src/converters - lazy_in_place_map.dart
Test
lcov.info
Date
2024-11-13
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines9090100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'package:meta/meta.dart';
2
3import 'converter.dart';
4
5@internal
6class LazyInPlaceMap<K, V> implements Map<K, V> {
72 LazyInPlaceMap(this._data, this._vcast);
8
9 final Map<dynamic, dynamic> _data;
10 final Cast<V> _vcast;
11
121 @override
131 Iterable<MapEntry<K, V>> get entries =>
146 keys.map((k) => MapEntry(k, _get(k) as V));
15
161 @override
173 bool get isEmpty => _data.isEmpty;
18
191 @override
203 bool get isNotEmpty => _data.isNotEmpty;
21
221 @override
234 Iterable<K> get keys => _data.keys.cast<K>();
24
251 @override
263 int get length => _data.length;
27
281 @override
291 Iterable<V> get values sync* {
304 final keys = _data.keys.toList();
314 for (var i = 0; i < keys.length; i++) {
323 yield _get(keys[i]) as V;
33 }
341 }
35
361 @override
372 V? operator [](Object? key) => _get(key);
38
391 @override
403 void operator []=(K key, V value) => _data[key] = value;
41
421 @override
433 void addAll(Map<K, V> other) => _data.addAll(other);
44
451 @override
461 void addEntries(Iterable<MapEntry<K, V>> newEntries) =>
473 _data.addEntries(newEntries);
48
491 @override
503 Map<RK, RV> cast<RK, RV>() => _forceCast().cast<RK, RV>();
51
521 @override
533 void clear() => _data.clear();
54
551 @override
563 bool containsKey(Object? key) => _data.containsKey(key);
57
581 @override
597 bool containsValue(Object? value) => _data.keys.any((k) => value == _get(k));
60
611 @override
621 void forEach(void Function(K key, V value) action) {
634 for (var k in _data.keys) {
643 action(k as K, _get(k) as V);
65 }
661 }
67
681 @override
691 Map<K2, V2> map<K2, V2>(MapEntry<K2, V2> Function(K key, V value) convert) {
705 final r = <K2, V2>{}, keys = _data.keys.toList();
715 for (var i = keys.length - 1; i >= 0; i--) {
724 final k = keys[i], e = convert(k as K, _get(k) as V);
734 r[e.key] = e.value;
74 }
751 return r;
761 }
77
781 @override
791 V putIfAbsent(K key, V Function() ifAbsent) =>
803 _data.putIfAbsent(key, ifAbsent);
81
821 @override
833 V? remove(Object? key) => _data.remove(key);
84
851 @override
861 void removeWhere(bool Function(K key, V value) test) {
874 final keys = _data.keys.toList();
885 for (var i = keys.length - 1; i >= 0; i--) {
893 final k = keys[i], v = _get(k);
902 if (test(k as K, v as V)) {
913 _data.remove(k);
92 }
93 }
941 }
95
961 @override
971 String toString() {
982 _forceCast();
993 return _data.toString();
1001 }
101
1021 @override
1031 V update(K key, V Function(V value) update, {V Function()? ifAbsent}) =>
1045 _data.update(key, (v) => (v != null && v is! V) ? _vcast(v) : v,
1051 ifAbsent: ifAbsent);
106
1071 @override
1081 void updateAll(V Function(K key, V value) update) {
1094 final keys = _data.keys.toList();
1105 for (var i = keys.length - 1; i >= 0; i--) {
1113 final k = keys[i], v = _get(k);
1124 _data[k] = update(k as K, v as V);
113 }
1141 }
115
1162 Map<dynamic, dynamic> _forceCast() {
1174 var keys = _data.keys.toList();
1185 for (var i = keys.length - 1; i >= 0; i--) {
1193 _get(keys[i]);
120 }
1212 return _data;
1221 }
123
1242 V? _get(Object? key) {
1253 dynamic v = _data[key];
1262 if (v != null && v is! V) {
1272 v = _vcast(v);
1282 _data[key] = v;
129 }
1301 return v;
1311 }
132}
Choose Features