This commit is contained in:
Simon Martens
2025-03-05 16:41:39 +01:00
commit e19fd47c17
88 changed files with 9765 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package functions
func MapArrayInsert[K comparable, V any](m map[K][]V, k K, v V) {
l, ok := m[k]
if !ok {
m[k] = []V{v}
} else {
m[k] = append(l, v)
}
}
func Keys[K comparable, V any](m map[K]V) []K {
keys := make([]K, 0, len(m))
for k := range m {
keys = append(keys, k)
}
return keys
}