Documentation
¶
Index ¶
- func Clear[K comparable, V any](m AnyMap[K, V])
- func Copy[K comparable, V any](dst AnyMap[K, V], src AnyMap[K, V])
- func DeleteFunc[K comparable, V any](m AnyMap[K, V], del func(K, V) bool)
- func Equal[K, V comparable](m1 AnyMap[K, V], m2 AnyMap[K, V]) bool
- func EqualFunc[K comparable, V any](m1 AnyMap[K, V], m2 AnyMap[K, V], eq func(V, V) bool) bool
- func FindValue[K comparable, V comparable](m ComparableMap[K, V], val V) (*K, bool)
- func HasKey[K comparable, V any](m AnyMap[K, V], key K) bool
- func Keys[K comparable, V any](m AnyMap[K, V]) []K
- func Values[K comparable, V any](m AnyMap[K, V]) []V
- type AnyMap
- type ByPair
- type ComparableMap
- type OrderedMap
- func (o *OrderedMap) Delete(key string)
- func (o *OrderedMap) Get(key string) (interface{}, bool)
- func (o *OrderedMap) Keys() []string
- func (o OrderedMap) MarshalJSON() ([]byte, error)
- func (o *OrderedMap) Set(key string, value interface{})
- func (o *OrderedMap) SetEscapeHTML(on bool)
- func (o *OrderedMap) Sort(lessFunc func(a *Pair, b *Pair) bool)
- func (o *OrderedMap) SortKeys(sortFunc func(keys []string))
- func (o *OrderedMap) UnmarshalJSON(b []byte) error
- func (o *OrderedMap) Values() map[string]interface{}
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteFunc ¶
func DeleteFunc[K comparable, V any](m AnyMap[K, V], del func(K, V) bool)
DeleteFunc deletes any key/value pairs from m for which del returns true.
func Equal ¶
func Equal[K, V comparable](m1 AnyMap[K, V], m2 AnyMap[K, V]) bool
Equal reports whether two maps contain the same key/value pairs. Values are compared using ==.
func EqualFunc ¶
EqualFunc is like Equal, but compares values using eq. Keys are still compared with ==.
func FindValue ¶
func FindValue[K comparable, V comparable](m ComparableMap[K, V], val V) (*K, bool)
判断map中是否存在对应的val
Types ¶
type ComparableMap ¶
type ComparableMap[K comparable, V comparable] map[K]V
type OrderedMap ¶
type OrderedMap struct {
// contains filtered or unexported fields
}
@bref OrderedMap 定义有序的键值对。
func NewOrderedMap ¶
func NewOrderedMap() *OrderedMap
@bref NewOrderedMap 创建新的有序的键值对。OrderedMap 默认启用HTML转义。
返回值:
@return *OrderedMap 有序的键值对
func (*OrderedMap) Delete ¶
func (o *OrderedMap) Delete(key string)
@bref Delete 从OrderedMap中删除指定的键值对。
参数:
@param key string 键
func (*OrderedMap) Get ¶
func (o *OrderedMap) Get(key string) (interface{}, bool)
@bref Get 从OrderedMap中根据给定的键获取对应的值。
参数:
@param key string 键
返回值:
@return interface{} 对应的值, 如果键不存在,则返回nil
@return bool 如果键不存在,则返回false
func (*OrderedMap) Keys ¶
func (o *OrderedMap) Keys() []string
@bref Keys 获取OrderedMap中所有的键。
返回值: @return []string 所有键
func (OrderedMap) MarshalJSON ¶
func (o OrderedMap) MarshalJSON() ([]byte, error)
@bref MarshalJSON 将 OrderedMap 转换为 JSON 格式的字节切片
返回值:
@return []byte 字节切片 @return error 错误
func (*OrderedMap) Set ¶
func (o *OrderedMap) Set(key string, value interface{})
@bref Set 将键值对存储到OrderedMap中。如果键已经存在,则更新其对应的值;
如果不存在,则添加新的键值对到OrderedMap中。
参数:
@param key string 键
@param value interface{} 值
func (*OrderedMap) SetEscapeHTML ¶
func (o *OrderedMap) SetEscapeHTML(on bool)
@bref SetEscapeHTML 设置OrderedMap是否启用HTML转义。
参数:
@param on bool 是否启用HTML转义
func (*OrderedMap) Sort ¶
func (o *OrderedMap) Sort(lessFunc func(a *Pair, b *Pair) bool)
@bref Sort 根据指定的排序函数对OrderedMap中的键进行排序。
参数:
@param lessFunc func(a *Pair, b *Pair) bool 排序函数, 返回true表示a排在b前面
func (*OrderedMap) SortKeys ¶
func (o *OrderedMap) SortKeys(sortFunc func(keys []string))
@bref SortKeys 排序OrderedMap中的键。
参数:
@param sortFunc func(keys []string) 排序函数
func (*OrderedMap) UnmarshalJSON ¶
func (o *OrderedMap) UnmarshalJSON(b []byte) error
@bref UnmarshalJSON 反序列化OrderedMap。
参数:
@param b []byte JSON字符串
func (*OrderedMap) Values ¶
func (o *OrderedMap) Values() map[string]interface{}
@bref Values 获取OrderedMap中所有的值。
返回值:
@return map[string]interface{} 所有值, 键值对以map的形式返回