Documentation
¶
Index ¶
- func ContainsKeys[K comparable, V any](super map[K]V, keys ...K) bool
- func ContainsKeysWithValues[K comparable, V any](super, sub map[K]V) bool
- func ContainsKeysWithValuesFunc[K comparable, V any](super, sub map[K]V, equal func(a, b V) bool) bool
- func Filter[K comparable, V any](m map[K]V, fil filters.Filter) map[K]V
- func GetAny[K comparable, V any](m map[K]V) *pairs.Pair[K, V]
- func Intersect[K comparable, V any](source map[K]V, maps ...map[K]V) map[K]V
- func Merge[K comparable, V any](maps ...map[K]V) map[K]V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsKeys ¶ added in v0.14.0
func ContainsKeys[K comparable, V any](super map[K]V, keys ...K) bool
ContainsKeys returns true if all given keys are present in the map.
func ContainsKeysWithValues ¶ added in v0.14.0
func ContainsKeysWithValues[K comparable, V any](super, sub map[K]V) bool
ContainsKeysWithValues checks if 'super' is a superset of 'sub', meaning that all keys of 'sub' are also present in 'super' with the same values. Uses reflect.DeepEqual to compare the values, use ContainsMapFunc if you want to use a custom equality function.
func ContainsKeysWithValuesFunc ¶ added in v0.14.0
func ContainsKeysWithValuesFunc[K comparable, V any](super, sub map[K]V, equal func(a, b V) bool) bool
ContainsKeysWithValuesFunc checks if 'super' is a superset of 'sub', meaning that all keys of 'sub' are also present in 'super' with the same values. The values are compared using the provided equality function. If the equality function returns false for any key-value pair, it returns false.
func Filter ¶
func Filter[K comparable, V any](m map[K]V, fil filters.Filter) map[K]V
Filter filters a map by applying a filter function to each key-value pair. Only the entries for which the filter function returns true are kept in the copy. The original map is not modified. Passes the key as first and the value as second argument into the filter function. Note that the values are not deep-copied. This is a convience alias for filters.FilterMap.
func GetAny ¶ added in v0.12.0
func GetAny[K comparable, V any](m map[K]V) *pairs.Pair[K, V]
GetAny returns an arbitrary key-value pair from the map as a pointer to a pairs.Pair. If the map is empty, it returns nil.
func Intersect ¶
func Intersect[K comparable, V any](source map[K]V, maps ...map[K]V) map[K]V
Intersect takes one source and any number of comparison maps and returns a new map containing only the entries of source for which keys exist in all comparison maps. The original maps are not modified. Note that the values are not deep-copied.
func Merge ¶
func Merge[K comparable, V any](maps ...map[K]V) map[K]V
Merge merges multiple maps into a single one. The original maps are not modified. Note that the values are not deep-copied. If multiple maps contain the same key, the value from the last map in the list is used.
Types ¶
This section is empty.