mirror of
				https://github.com/Theodor-Springmann-Stiftung/musenalm.git
				synced 2025-10-29 09:15:33 +00:00 
			
		
		
		
	Preferred title in entries & unused fields in contents
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| package datatypes | ||||
|  | ||||
| // INFO: use this if your key is unique | ||||
| func MakeMap[T any, U comparable](data []T, f func(T) U) map[U]T { | ||||
| 	m := make(map[U]T) | ||||
| 	for _, v := range data { | ||||
| @@ -7,3 +8,12 @@ func MakeMap[T any, U comparable](data []T, f func(T) U) map[U]T { | ||||
| 	} | ||||
| 	return m | ||||
| } | ||||
|  | ||||
| // INFO: use this if your key is not unique | ||||
| func MakeMultiMap[T any, U comparable](data []T, f func(T) U) map[U][]T { | ||||
| 	m := make(map[U][]T) | ||||
| 	for _, v := range data { | ||||
| 		m[f(v)] = append(m[f(v)], v) | ||||
| 	} | ||||
| 	return m | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Simon Martens
					Simon Martens