Documentation ¶
Index ¶
- func Filter[TVal any, TKey comparable](fn func(v TVal) (bool, TVal), values map[TKey]TVal) (ret []TVal)
- func GetKeys[T1 comparable, T2 ...](sources map[T1]T2) []T1
- func GetValue(obj map[string]any, key string, def any) any
- func GetValues[K comparable, V any | ~struct{}](target map[K]V) []V
- func Pluck[V any, R any](slice []V, key, val string) ([]map[string]R, error)
- func SetValue(obj map[string]any, key string, val, def any)
- func Zip[TKey ..., TVal ...](keys []TKey, values []TVal) (zip map[TKey]TVal, err error)
- type AnyDict
- func (r *AnyDict[K, V]) All() map[K]V
- func (r *AnyDict[K, V]) AllEmpty() bool
- func (r *AnyDict[K, V]) AnyEmpty() bool
- func (r *AnyDict[K, V]) Filter(fn func(V) bool) *AnyDict[K, V]
- func (r *AnyDict[K, V]) Get(key K) (V, bool)
- func (r *AnyDict[K, V]) GetKeysByValue(value *array.AnyArray[V]) *array.AnyArray[K]
- func (r *AnyDict[K, V]) InKey(target K) bool
- func (r *AnyDict[K, V]) InVal(target V) bool
- func (r *AnyDict[K, V]) JoinWithoutEmpty(sep string) string
- func (r *AnyDict[K, V]) Len() int
- func (r *AnyDict[K, V]) RemoveByKey(key K) *AnyDict[K, V]
- func (r *AnyDict[K, V]) RemoveByKeys(keys ...K) *AnyDict[K, V]
- func (r *AnyDict[K, V]) RemoveByValue(value V) *AnyDict[K, V]
- func (r *AnyDict[K, V]) RemoveByValues(values ...V) *AnyDict[K, V]
- func (r *AnyDict[K, T]) RemoveEmpty() *AnyDict[K, T]
- func (r *AnyDict[K, V]) Set(key K, value V) *AnyDict[K, V]
- func (r *AnyDict[K, V]) ToAnyList() *array.AnyArray[V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter[TVal any, TKey comparable](fn func(v TVal) (bool, TVal), values map[TKey]TVal) (ret []TVal)
Filter 过滤数组
func GetKeys ¶
func GetKeys[T1 comparable, T2 any | ~struct{} | string | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](sources map[T1]T2) []T1
GetKeys 获取一个字典中所有的key
func GetValues ¶ added in v1.2.0
func GetValues[K comparable, V any | ~struct{}](target map[K]V) []V
GetValues 获取一个字典中所有的value
Types ¶
type AnyDict ¶ added in v1.6.0
type AnyDict[K comparable, V any] struct { // contains filtered or unexported fields }
func NewAnyDict ¶ added in v1.6.0
func NewAnyDict[K comparable, V any]() *AnyDict[K, V]
func (*AnyDict[K, V]) GetKeysByValue ¶ added in v1.6.0
GetKeysByValue 通过值找到所有对应的key
func (*AnyDict[K, V]) JoinWithoutEmpty ¶ added in v1.6.0
JoinWithoutEmpty 拼接非空元素
func (*AnyDict[K, V]) RemoveByKey ¶ added in v1.6.0
RemoveByKey 根据key删除元素
func (*AnyDict[K, V]) RemoveByKeys ¶ added in v1.6.0
RemoveByKeys 根据key批量删除元素
func (*AnyDict[K, V]) RemoveByValue ¶ added in v1.6.0
RemoveByValue 根据值删除元素
func (*AnyDict[K, V]) RemoveByValues ¶ added in v1.6.0
RemoveByValues 根据值批量删除元素
func (*AnyDict[K, T]) RemoveEmpty ¶ added in v1.6.0
RemoveEmpty 清除空值元素
Click to show internal directories.
Click to hide internal directories.