From 877ee125498e3ab07a54d1fa34791ea0a879e6ca Mon Sep 17 00:00:00 2001 From: surdeus Date: Fri, 28 Jul 2023 20:48:02 +0300 Subject: [PATCH] ... --- src/mapx/misc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/mapx/misc.go diff --git a/src/mapx/misc.go b/src/mapx/misc.go new file mode 100644 index 0000000..2499c53 --- /dev/null +++ b/src/mapx/misc.go @@ -0,0 +1,10 @@ +package mapx + +func Reversed[K, V comparable](m map[K] V) map[V] K { + r := make(map[V] K) + for k, v := range m { + r[v] = k + } + return r +} +