open-consul/lib/maps/maps.go
Ronald 71fb0a723e
Copyright headers for missing files/folders (#16708)
* copyright headers for agent folder
2023-03-28 18:48:58 -04:00

27 lines
446 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package maps
func SliceOfKeys[K comparable, V any](m map[K]V) []K {
if len(m) == 0 {
return nil
}
res := make([]K, 0, len(m))
for k := range m {
res = append(res, k)
}
return res
}
func SliceOfValues[K comparable, V any](m map[K]V) []V {
if len(m) == 0 {
return nil
}
res := make([]V, 0, len(m))
for _, v := range m {
res = append(res, v)
}
return res
}