maps

package
v0.0.0-...-d05e8a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy[K constraints.Ordered, V any](m map[K]V) map[K]V

Copy 拷贝map

func Filter

func Filter[K constraints.Ordered, V any](m map[K]V, pred func(K, V) bool) map[K]V

Filter 字典过滤,移除不满足pred函数的元素

func FilterMap

func FilterMap[K constraints.Ordered, V1, V2 any](m map[K]V1, pred func(K, V1) (V2, bool)) map[K]V2

FilterMap 过滤字典并映射

func Keys

func Keys[K constraints.Ordered, V any](m map[K]V) []K

Keys 返回字典的键列表

func ListAppend

func ListAppend[K constraints.Ordered, V any](m map[K][]V, k K, v V, exist bool) bool

ListAppend 列表扩展

func ListInsert

func ListInsert[K constraints.Ordered, V constraints.Ordered](m map[K][]V, k K, v V, exist bool) bool

ListInsert 列表插入

func ListRemove

func ListRemove[K constraints.Ordered, V constraints.Ordered](m map[K][]V, k K, v V) bool

ListRemove 列表移除

func Map

func Map[K constraints.Ordered, V1, V2 any](m map[K]V1, fun func(K, V1) V2) map[K]V2

Map 字典映射

func Merge

func Merge[K constraints.Ordered, V any](m1, m2 map[K]V) map[K]V

Merge 合并两个map,存在相同key时使用m2中的值

func MergeWith

func MergeWith[K constraints.Ordered, V any](m1, m2 map[K]V, combiner func(k K, v1, v2 V) V) map[K]V

MergeWith 合并两个map,存在相同key时使用combiner函数的返回值

func MergeWithAdd

func MergeWithAdd[K constraints.Ordered, V types.Number](m1, m2 map[K]V) map[K]V

MergeWithAdd 合并两个map,存在相同key时将其值相加

func MergeWithSub

func MergeWithSub[K constraints.Ordered, V types.Number](m1, m2 map[K]V) map[K]V

func Values

func Values[K constraints.Ordered, V any](m map[K]V) []V

Values 返回字典的值列表

func With

func With[K constraints.Ordered, V any](m map[K]V, keys []K) map[K]V

With 保留字典中键在keys列表中的项

func Without

func Without[K constraints.Ordered, V any](m map[K]V, keys []K) map[K]V

Without 保留字典中键不在keys列表中的项

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL