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]) Clean() *AnyDict[K, V]
- 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]) Keys() []K
- 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]
- func (r *AnyDict[K, V]) Values() []V
- type AnyOrderlyDict
- func (r *AnyOrderlyDict[K, V]) All() []*OrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) Clean() *AnyOrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) Copy() *AnyOrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) Filter(fn func(dict *OrderlyDict[K, V]) bool) *AnyOrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) First() *OrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) FirstKey() K
- func (r *AnyOrderlyDict[K, V]) FirstValue() V
- func (r *AnyOrderlyDict[K, V]) Get(key K) (V, bool)
- func (r *AnyOrderlyDict[K, V]) Keys() []K
- func (r *AnyOrderlyDict[K, V]) Last() *OrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) LastKey() K
- func (r *AnyOrderlyDict[K, V]) LastValue() V
- func (r *AnyOrderlyDict[K, V]) Len() int
- func (r *AnyOrderlyDict[K, V]) SetByIndex(index int, key K, value V) *AnyOrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) SetByKey(key K, value V) *AnyOrderlyDict[K, V]
- func (r *AnyOrderlyDict[K, V]) ToMap() map[K]V
- type OrderlyDict
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 ¶
func GetValues[K comparable, V any | ~struct{}](target map[K]V) []V
GetValues 获取一个字典中所有的value
Types ¶
type AnyDict ¶
type AnyDict[K comparable, V any] struct { // contains filtered or unexported fields }
func MakeAnyDict ¶
func MakeAnyDict[K comparable, V any]() *AnyDict[K, V]
func NewAnyDict ¶
func NewAnyDict[K comparable, V any](dict map[K]V) *AnyDict[K, V]
func (*AnyDict[K, V]) GetKeysByValue ¶
GetKeysByValue 通过值找到所有对应的key
func (*AnyDict[K, V]) JoinWithoutEmpty ¶
JoinWithoutEmpty 拼接非空元素
func (*AnyDict[K, V]) RemoveByKey ¶
RemoveByKey 根据key删除元素
func (*AnyDict[K, V]) RemoveByKeys ¶
RemoveByKeys 根据key批量删除元素
func (*AnyDict[K, V]) RemoveByValue ¶
RemoveByValue 根据值删除元素
func (*AnyDict[K, V]) RemoveByValues ¶
RemoveByValues 根据值批量删除元素
func (*AnyDict[K, T]) RemoveEmpty ¶
RemoveEmpty 清除空值元素
type AnyOrderlyDict ¶
type AnyOrderlyDict[K comparable, V any] struct { // contains filtered or unexported fields }
func MakeAnyOrderlyDict ¶
func MakeAnyOrderlyDict[K comparable, V any](size int) *AnyOrderlyDict[K, V]
MakeAnyOrderlyDict 格式化:有序字典
func NewAnyOrderlyDict ¶
func NewAnyOrderlyDict[K comparable, V any](m map[K]V, keys ...K) *AnyOrderlyDict[K, V]
NewAnyOrderlyDict 实例化:有序字典
func (*AnyOrderlyDict[K, V]) All ¶
func (r *AnyOrderlyDict[K, V]) All() []*OrderlyDict[K, V]
All 获取所有值
func (*AnyOrderlyDict[K, V]) Clean ¶
func (r *AnyOrderlyDict[K, V]) Clean() *AnyOrderlyDict[K, V]
Clean 清理
func (*AnyOrderlyDict[K, V]) Copy ¶
func (r *AnyOrderlyDict[K, V]) Copy() *AnyOrderlyDict[K, V]
Copy 拷贝对象
func (*AnyOrderlyDict[K, V]) Filter ¶
func (r *AnyOrderlyDict[K, V]) Filter(fn func(dict *OrderlyDict[K, V]) bool) *AnyOrderlyDict[K, V]
Filter 通过条件过滤
func (*AnyOrderlyDict[K, V]) First ¶
func (r *AnyOrderlyDict[K, V]) First() *OrderlyDict[K, V]
First 获取第一个键值对
func (*AnyOrderlyDict[K, V]) FirstKey ¶
func (r *AnyOrderlyDict[K, V]) FirstKey() K
FirstKey 获取第一个key
func (*AnyOrderlyDict[K, V]) FirstValue ¶
func (r *AnyOrderlyDict[K, V]) FirstValue() V
FirstValue 获取第一个值
func (*AnyOrderlyDict[K, V]) Last ¶
func (r *AnyOrderlyDict[K, V]) Last() *OrderlyDict[K, V]
Last 获取最后一个键值对
func (*AnyOrderlyDict[K, V]) LastValue ¶
func (r *AnyOrderlyDict[K, V]) LastValue() V
LastValue 获取最后一个值
func (*AnyOrderlyDict[K, V]) SetByIndex ¶ added in v2.2.1
func (r *AnyOrderlyDict[K, V]) SetByIndex(index int, key K, value V) *AnyOrderlyDict[K, V]
SetByIndex 设置值:根据索引
type OrderlyDict ¶
type OrderlyDict[K comparable, V any] struct { Key K Value V }
func NewOrderlyDict ¶
func NewOrderlyDict[K comparable, V any](key K, value V) *OrderlyDict[K, V]
NewOrderlyDict 实例化:有序字典项
Click to show internal directories.
Click to hide internal directories.