This commit is contained in:
2025-03-03 16:10:03 +02:00
parent ec17d94cb9
commit 24cd167754
5 changed files with 21 additions and 20 deletions

View File

@@ -0,0 +1,15 @@
Map<T, B> mergeAllMaps<T, B>(List<Map<T, B>> maps, {Function(T key, B value1, B value2)? repeatingKeysValueComparer}) {
Map<T, B> r = <T,B>{};
//
for (Map<T, B> m in maps) {
m.forEach((T key,B value) {
if (!r.containsKey(key)) {
r.addEntries(<MapEntry<T, B>>[MapEntry<T,B>(key, value)]);
} else {
repeatingKeysValueComparer?.call(key, r[key] as B, value);
}
});
}
//
return r;
}