github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/pkg/piperutils/maps.go (about)

     1  package piperutils
     2  
     3  func Keys[M ~map[K]V, K comparable, V any](m M) []K {
     4  	r := make([]K, 0, len(m))
     5  	for k := range m {
     6  		r = append(r, k)
     7  	}
     8  	return r
     9  }
    10  
    11  // Values returns the slice of values of the map provided
    12  func Values[M ~map[K]V, K comparable, V any](m M) []V {
    13  	r := make([]V, 0, len(m))
    14  	for _, v := range m {
    15  		r = append(r, v)
    16  	}
    17  	return r
    18  }