Documentation
¶
Index ¶
- func Filter[M ~map[K]V, K comparable, V comparable](m M) M
- func FilterFunc[M ~map[K]V, K comparable, V any](m M, f func(K, V) bool) M
- func Set[M map[K]struct{}, K comparable](ks ...K) (m M)
- func Split[M ~map[K]V, K comparable, V any](m M, sep int) []M
- func SplitN[M ~map[K]V, K comparable, V any](m M, sep int, n int) []M
- func TypeAssertFilter[M ~map[K]V, M2 ~map[K2]V2, K comparable, V comparable, K2 comparable, ...](m M) M2
- func TypeAssertFilterFunc[M ~map[K]V, M2 ~map[K2]V2, K comparable, V any, K2 comparable, V2 any](m M, f func(K, V) (K2, V2, bool)) M2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶ added in v1.2.59
func Filter[M ~map[K]V, K comparable, V comparable](m M) M
Filter returns a map satisfying c != zero within all c in the map. Filter modifies the contents of the map s; it does not create a new map.
func FilterFunc ¶ added in v1.2.59
func FilterFunc[M ~map[K]V, K comparable, V any](m M, f func(K, V) bool) M
FilterFunc returns a map satisfying f(c) within all c in the map. FilterFunc modifies the contents of the map s; it does not create a new map.
func Set ¶ added in v1.2.26
func Set[M map[K]struct{}, K comparable](ks ...K) (m M)
Set implements a non-thread safe Set
func Split ¶ added in v1.2.40
func Split[M ~map[K]V, K comparable, V any](m M, sep int) []M
Split slices s into all submaps separated by sep and returns a slice of the submaps between those separators.
If s is less than sep and sep is more than zero, Split returns a slice of length 1 whose only element is s.
If s is nil, Split returns nil (zero submaps).
If both s and sep are empty or zero, Split returns an empty slice.
If sep is <= zero, Split splits after each element, as chunk size is 1.
It is equivalent to SplitN with a count of -1.
func SplitN ¶
func SplitN[M ~map[K]V, K comparable, V any](m M, sep int, n int) []M
SplitN slices s into submaps and returns a slice of the submaps.
The count determines the number of submaps to return:
n > 0: at most n submaps; the last submaps will be the unsplit remainder. The count determines the number of submaps to return: sep > 0: Split splits every sep as chunk size; the last submaps will be the unsplit remainder. sep <= 0: take len(S)/n as chunk size n == 0: the result is nil (zero submaps) n < 0: all submaps as n == len(s)
Edge cases for s and sep (for example, zero) are handled as described in the documentation for Split.
func TypeAssertFilter ¶ added in v1.2.59
func TypeAssertFilter[M ~map[K]V, M2 ~map[K2]V2, K comparable, V comparable, K2 comparable, V2 comparable](m M) M2
TypeAssertFilter returns a map satisfying r, ok := any(c).(R); ok == true within all r in the map. TypeAssertFilter does not modify the contents of the map m; it creates a new map.
func TypeAssertFilterFunc ¶ added in v1.2.59
func TypeAssertFilterFunc[M ~map[K]V, M2 ~map[K2]V2, K comparable, V any, K2 comparable, V2 any](m M, f func(K, V) (K2, V2, bool)) M2
TypeAssertFilterFunc returns a map satisfying f(c) within all c in the map. TypeAssertFilterFunc does not modify the contents of the map m; it creates a new map.
Types ¶
This section is empty.