Documentation ¶
Index ¶
- func Assign[K comparable, V any](maps ...map[K]V) map[K]V
- func FindKey[K comparable, V comparable](object map[K]V, value V) (K, bool)
- func FindKeyBy[K comparable, V any](object map[K]V, predicate func(key K, value V) bool) (K, bool)
- func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
- func FromPairs[K comparable, V any](entries []Entry[K, V]) map[K]V
- func Invert[K comparable, V comparable](in map[K]V) map[V]K
- func Keys[K comparable, V any](in map[K]V) []K
- func MapEntries[K1 comparable, V1 any, K2 comparable, V2 any](in map[K1]V1, iteratee func(key K1, value V1) (K2, V2)) map[K2]V2
- func MapKeys[K comparable, V any, R comparable](in map[K]V, iteratee func(value V, key K) R) map[R]V
- func MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) R) []R
- func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(value V, key K) R) map[K]R
- func OmitBy[K comparable, V any](in map[K]V, predicate func(key K, value V) bool) map[K]V
- func OmitByKeys[K comparable, V any](in map[K]V, keys []K) map[K]V
- func OmitByValues[K comparable, V comparable](in map[K]V, values []V) map[K]V
- func PickBy[K comparable, V any](in map[K]V, predicate func(key K, value V) bool) map[K]V
- func PickByKeys[K comparable, V any](in map[K]V, keys []K) map[K]V
- func PickByValues[K comparable, V comparable](in map[K]V, values []V) map[K]V
- func Values[K comparable, V any](in map[K]V) []V
- type Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
func Assign[K comparable, V any](maps ...map[K]V) map[K]V
Assign 合并多个map Play: https://go.dev/play/p/VhwfJOyxf5o
func FindKey ¶
func FindKey[K comparable, V comparable](object map[K]V, value V) (K, bool)
FindKey 通过map的value查找key
func FindKeyBy ¶
func FindKeyBy[K comparable, V any](object map[K]V, predicate func(key K, value V) bool) (K, bool)
FindKeyBy 通过规定的函数查找map的key
func FromEntries ¶
func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
FromEntries Entry类型的切片转换为map Play: https://go.dev/play/p/oIr5KHFGCEN
func FromPairs ¶
func FromPairs[K comparable, V any](entries []Entry[K, V]) map[K]V
FromPairs FromEntries的别名 Play: https://go.dev/play/p/oIr5KHFGCEN
func Invert ¶
func Invert[K comparable, V comparable](in map[K]V) map[V]K
Invert 调换map的key和value,如果value存在重复的,则后面遍历的会覆盖前面的 Play: https://go.dev/play/p/rFQ4rak6iA1
func Keys ¶
func Keys[K comparable, V any](in map[K]V) []K
Keys 通过map的key构造切片 Play: https://go.dev/play/p/Uu11fHASqrU
func MapEntries ¶
func MapEntries[K1 comparable, V1 any, K2 comparable, V2 any](in map[K1]V1, iteratee func(key K1, value V1) (K2, V2)) map[K2]V2
MapEntries 遍历map,并将map的key和value通过iteratee转换为另一个值作为新的map的key和value Play: https://go.dev/play/p/VuvNQzxKimT
func MapKeys ¶
func MapKeys[K comparable, V any, R comparable](in map[K]V, iteratee func(value V, key K) R) map[R]V
MapKeys 遍历map,并将map的key通过iteratee转换为另一个值作为新的map的key Play: https://go.dev/play/p/9_4WPIqOetJ
func MapToSlice ¶
func MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) R) []R
MapToSlice 遍历map,并通过iteratee,将map的key和value进行转换作为新的切片的值 Play: https://go.dev/play/p/ZuiCZpDt6LD
func MapValues ¶
func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(value V, key K) R) map[K]R
MapValues 遍历map,并将map的value通过iteratee转换为另一个值作为新的map的value Play: https://go.dev/play/p/T_8xAfvcf0W
func OmitBy ¶
func OmitBy[K comparable, V any](in map[K]V, predicate func(key K, value V) bool) map[K]V
OmitBy PickBy的相反结果,不满足给定条件的数据过滤map Play: https://go.dev/play/p/EtBsR43bdsd
func OmitByKeys ¶
func OmitByKeys[K comparable, V any](in map[K]V, keys []K) map[K]V
OmitByKeys 过滤key不在切片里的map数据 Play: https://go.dev/play/p/t1QjCrs-ysk
func OmitByValues ¶
func OmitByValues[K comparable, V comparable](in map[K]V, values []V) map[K]V
OmitByValues 过滤value不在切片里的map数据 Play: https://go.dev/play/p/9UYZi-hrs8j
func PickBy ¶
func PickBy[K comparable, V any](in map[K]V, predicate func(key K, value V) bool) map[K]V
PickBy 根据给定的条件过滤map Play: https://go.dev/play/p/kdg8GR_QMmf
func PickByKeys ¶
func PickByKeys[K comparable, V any](in map[K]V, keys []K) map[K]V
PickByKeys 过滤key在切片里的map数据 Play: https://go.dev/play/p/R1imbuci9qU
func PickByValues ¶
func PickByValues[K comparable, V comparable](in map[K]V, values []V) map[K]V
PickByValues 过滤value在切片里的map数据 Play: https://go.dev/play/p/1zdzSvbfsJc
func Values ¶
func Values[K comparable, V any](in map[K]V) []V
Values 通过map的value构造切片 Play: https://go.dev/play/p/nnRTQkzQfF6
Types ¶
type Entry ¶
type Entry[K comparable, V any] struct { Key K Value V }
func Entries ¶
func Entries[K comparable, V any](in map[K]V) []Entry[K, V]
Entries 将map转换为Entry类型的切片,类似java里面的Entry
func ToPairs ¶
func ToPairs[K comparable, V any](in map[K]V) []Entry[K, V]
ToPairs Entries的别名 Play: https://go.dev/play/p/3Dhgx46gawJ