From 433cd9ee4c31e41873aec9a88c2a6fae8bdb4cb5 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:01:09 +0200 Subject: [PATCH] feat(utils): Add KeysAsSet --- utils/common.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/common.go b/utils/common.go index e4b16e6..7fb84ca 100644 --- a/utils/common.go +++ b/utils/common.go @@ -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)