Documentation ¶
Overview ¶
Package structs provides basic operations with maps and slices
Package structs provides basic operations with maps and slices ¶
Package structs provides basic operations with maps and slices
Index ¶
- func FilterMap[K comparable, V any](collection map[K]V, filter func(V) bool) map[K]V
- func FilterSlice[V any](collection []V, filter func(V) bool) []V
- func ForEach[T any](collection []T, f func(T))
- func If[V any](condition bool, then V, els V) V
- func IfVal[V any](condition bool, then *V, els *V) V
- func Keys[K comparable, V any](in map[K]V) []K
- func Map[T any, R any](collection []T, f func(T) R) []R
- func MapWithError[T any, R any](collection []T, f func(T) (R, error)) ([]R, error)
- func Ref[V comparable](v V) *V
- func SliceToMap[K comparable, V any](collection []V, key func(V) K) map[K]V
- func SliceToMapOfStruct[K comparable, V any](collection []V, key func(V) K) map[K]struct{}
- func Val[V comparable](v *V) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterMap ¶
func FilterMap[K comparable, V any](collection map[K]V, filter func(V) bool) map[K]V
FilterMap filters the map.
func FilterSlice ¶
FilterSlice is a filter function.
func MapWithError ¶
MapWithError is a map function with error returns.
func SliceToMap ¶
func SliceToMap[K comparable, V any](collection []V, key func(V) K) map[K]V
SliceToMap converts slice of structs to map.
func SliceToMapOfStruct ¶
func SliceToMapOfStruct[K comparable, V any](collection []V, key func(V) K) map[K]struct{}
SliceToMapOfStruct converts slice of structs to map of struct.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.