map<RK, RV> method
Returns a new map where all entries of this map are transformed by
the given mapper
function. However, if ifRemove
is provided,
the mapped value will first be tested with it and, if ifRemove
returns true, the value will be removed from the result map.
Implementation
IMap<RK, RV> map<RK, RV>(
MapEntry<RK, RV> Function(K key, V value) mapper, {
bool Function(RK key, RV value)? ifRemove,
ConfigMap? config,
}) {
config ??= defaultConfig;
Map<RK, RV> map = ListMap.fromEntries(
entries
.map((entry) => mapper(entry.key, entry.value))
.where((entry) => ifRemove == null || !ifRemove(entry.key, entry.value)),
sort: config.sort,
);
return IMap._unsafeFromMap(map, config: config);
}