GetMapKeys returns the map's keys as an unsorted slice.
(m map[K]V)
| 27 | |
| 28 | // GetMapKeys returns the map's keys as an unsorted slice. |
| 29 | func GetMapKeys[K comparable, V any](m map[K]V) []K { |
| 30 | allKeys := make([]K, len(m)) |
| 31 | i := 0 |
| 32 | for k := range m { |
| 33 | allKeys[i] = k |
| 34 | i++ |
| 35 | } |
| 36 | return allKeys |
| 37 | } |
| 38 | |
| 39 | // GetMapKeysSorted returns the map's keys as a sorted slice. The keys are sorted in ascending order. For descending |
| 40 | // order, use GetMapKeysSortedDescending. |
no outgoing calls
no test coverage detected