Skip to content

Commit

Permalink
add MapToSlice method (#28)
Browse files Browse the repository at this point in the history
* add MapToSlice method

* change name
  • Loading branch information
zreigz authored Mar 15, 2024
1 parent 1712923 commit a9a52c8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions algorithms/map.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package algorithms

func MapValues[K comparable, V any](m map[K]V) []V {
s := make([]V, 0, len(m))
for _, v := range m {
s = append(s, v)
}
return s
}

func Merge(maps ...map[string]interface{}) map[string]interface{} {
res := maps[0]
for _, m := range maps[1:] {
Expand Down

0 comments on commit a9a52c8

Please sign in to comment.