dict

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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 GetValue

func GetValue(obj map[string]any, key string, def any) any

GetValue 获取值

func GetValues added in v1.2.0

func GetValues[K comparable, V any | ~struct{}](target map[K]V) []V

GetValues 获取一个字典中所有的value

func Pluck added in v1.4.3

func Pluck[V any, R any](slice []V, key, val string) ([]map[string]R, error)

Pluck 从切片提取到map

func SetValue

func SetValue(obj map[string]any, key string, val, def any)

SetValue 设置值

func Zip

func Zip[TKey ~struct{} | string | int |
	int8 | int16 | int32 | int64 | uint |
	uint8 | uint16 | uint32 | uint64,
	TVal ~struct{} | string | int |
		int8 | int16 | int32 | int64 | uint |
		uint8 | uint16 | uint32 | uint64](keys []TKey, values []TVal) (zip map[TKey]TVal, err error)

Zip 压缩数据到map

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]) All added in v1.6.0

func (r *AnyDict[K, V]) All() map[K]V

All 获取全部元素

func (*AnyDict[K, V]) AllEmpty added in v1.6.0

func (r *AnyDict[K, V]) AllEmpty() bool

AllEmpty 检查是否全部为空

func (*AnyDict[K, V]) AnyEmpty added in v1.6.0

func (r *AnyDict[K, V]) AnyEmpty() bool

AnyEmpty 检查是否存在空值

func (*AnyDict[K, V]) Filter added in v1.6.0

func (r *AnyDict[K, V]) Filter(fn func(V) bool) *AnyDict[K, V]

Filter 过滤元素

func (*AnyDict[K, V]) Get added in v1.6.0

func (r *AnyDict[K, V]) Get(key K) (V, bool)

Get 获取元素

func (*AnyDict[K, V]) GetKeysByValue added in v1.6.0

func (r *AnyDict[K, V]) GetKeysByValue(value *array.AnyArray[V]) *array.AnyArray[K]

GetKeysByValue 通过值找到所有对应的key

func (*AnyDict[K, V]) InKey added in v1.6.0

func (r *AnyDict[K, V]) InKey(target K) bool

InKey 检查key是否存在

func (*AnyDict[K, V]) InVal added in v1.6.0

func (r *AnyDict[K, V]) InVal(target V) bool

InVal 检查值是否存在

func (*AnyDict[K, V]) JoinWithoutEmpty added in v1.6.0

func (r *AnyDict[K, V]) JoinWithoutEmpty(sep string) string

JoinWithoutEmpty 拼接非空元素

func (*AnyDict[K, V]) Len added in v1.6.0

func (r *AnyDict[K, V]) Len() int

Len 获取长度

func (*AnyDict[K, V]) RemoveByKey added in v1.6.0

func (r *AnyDict[K, V]) RemoveByKey(key K) *AnyDict[K, V]

RemoveByKey 根据key删除元素

func (*AnyDict[K, V]) RemoveByKeys added in v1.6.0

func (r *AnyDict[K, V]) RemoveByKeys(keys ...K) *AnyDict[K, V]

RemoveByKeys 根据key批量删除元素

func (*AnyDict[K, V]) RemoveByValue added in v1.6.0

func (r *AnyDict[K, V]) RemoveByValue(value V) *AnyDict[K, V]

RemoveByValue 根据值删除元素

func (*AnyDict[K, V]) RemoveByValues added in v1.6.0

func (r *AnyDict[K, V]) RemoveByValues(values ...V) *AnyDict[K, V]

RemoveByValues 根据值批量删除元素

func (*AnyDict[K, T]) RemoveEmpty added in v1.6.0

func (r *AnyDict[K, T]) RemoveEmpty() *AnyDict[K, T]

RemoveEmpty 清除空值元素

func (*AnyDict[K, V]) Set added in v1.6.0

func (r *AnyDict[K, V]) Set(key K, value V) *AnyDict[K, V]

Set 设置元素

func (*AnyDict[K, V]) ToAnyList added in v1.6.0

func (r *AnyDict[K, V]) ToAnyList() *array.AnyArray[V]

ToAnyList 转any list

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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