feat(utils): Add KeysAsSet

This commit is contained in:
Myzel394 2024-08-05 21:01:09 +02:00
parent 3f102e283d
commit 433cd9ee4c
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185

View File

@ -73,6 +73,16 @@ func FilterMapWhere[T comparable, O any](values map[T]O, f func(T, O) bool) map[
return result
}
func KeysAsSet[T comparable, O any](values map[T]O) map[T]struct{} {
set := make(map[T]struct{})
for key := range values {
set[key] = struct{}{}
}
return set
}
func KeysOfMap[T comparable, O any](values map[T]O) []T {
keys := make([]T, 0)