MapKeys returns the keys of a map as a slice.
(m any)
| 113 | |
| 114 | // MapKeys returns the keys of a map as a slice. |
| 115 | func MapKeys(m any) []any { |
| 116 | if m == nil { |
| 117 | return nil |
| 118 | } |
| 119 | rv := reflect.ValueOf(m) |
| 120 | if rv.Kind() != reflect.Map { |
| 121 | panic(fmt.Errorf("expected %T to be of map type", m)) |
| 122 | } |
| 123 | ks := make([]any, 0, rv.Len()) |
| 124 | for _, k := range rv.MapKeys() { |
| 125 | ks = append(ks, k.Interface()) |
| 126 | } |
| 127 | return ks |
| 128 | } |
| 129 | |
| 130 | // IsSubsetOfElements returns true iff a multiset sub represents a subset of |
| 131 | // multiset super under equality given by eq. |