Documentation ¶
Overview ¶
Package gmap provides kinds of concurrent-safe(alternative) maps.
并发安全MAP.
Index ¶
- type IntBoolMap
- func (gm *IntBoolMap) BatchRemove(keys []int)
- func (gm *IntBoolMap) BatchSet(m map[int]bool)
- func (gm *IntBoolMap) Clear()
- func (gm *IntBoolMap) Clone() *IntBoolMap
- func (gm *IntBoolMap) Contains(key int) bool
- func (gm *IntBoolMap) Get(key int) bool
- func (gm *IntBoolMap) GetOrSet(key int, value bool) bool
- func (gm *IntBoolMap) GetOrSetFunc(key int, f func() bool) bool
- func (gm *IntBoolMap) GetOrSetFuncLock(key int, f func() bool) bool
- func (gm *IntBoolMap) IsEmpty() bool
- func (gm *IntBoolMap) Iterator(f func(k int, v bool) bool)
- func (gm *IntBoolMap) Keys() []int
- func (gm *IntBoolMap) LockFunc(f func(m map[int]bool))
- func (gm *IntBoolMap) Map() map[int]bool
- func (gm *IntBoolMap) Merge(m *IntBoolMap)
- func (gm *IntBoolMap) RLockFunc(f func(m map[int]bool))
- func (gm *IntBoolMap) Remove(key int) bool
- func (gm *IntBoolMap) Set(key int, val bool)
- func (gm *IntBoolMap) SetIfNotExist(key int, value bool) bool
- func (gm *IntBoolMap) Size() int
- type IntIntMap
- func (gm *IntIntMap) BatchRemove(keys []int)
- func (gm *IntIntMap) BatchSet(m map[int]int)
- func (gm *IntIntMap) Clear()
- func (gm *IntIntMap) Clone() *IntIntMap
- func (gm *IntIntMap) Contains(key int) bool
- func (gm *IntIntMap) Flip()
- func (gm *IntIntMap) Get(key int) int
- func (gm *IntIntMap) GetOrSet(key int, value int) int
- func (gm *IntIntMap) GetOrSetFunc(key int, f func() int) int
- func (gm *IntIntMap) GetOrSetFuncLock(key int, f func() int) int
- func (gm *IntIntMap) IsEmpty() bool
- func (gm *IntIntMap) Iterator(f func(k int, v int) bool)
- func (gm *IntIntMap) Keys() []int
- func (gm *IntIntMap) LockFunc(f func(m map[int]int))
- func (gm *IntIntMap) Map() map[int]int
- func (gm *IntIntMap) Merge(m *IntIntMap)
- func (gm *IntIntMap) RLockFunc(f func(m map[int]int))
- func (gm *IntIntMap) Remove(key int) int
- func (gm *IntIntMap) Set(key int, val int)
- func (gm *IntIntMap) SetIfNotExist(key int, value int) bool
- func (gm *IntIntMap) Size() int
- func (gm *IntIntMap) Values() []int
- type IntInterfaceMap
- func (gm *IntInterfaceMap) BatchRemove(keys []int)
- func (gm *IntInterfaceMap) BatchSet(m map[int]interface{})
- func (gm *IntInterfaceMap) Clear()
- func (gm *IntInterfaceMap) Clone() *IntInterfaceMap
- func (gm *IntInterfaceMap) Contains(key int) bool
- func (gm *IntInterfaceMap) Flip()
- func (gm *IntInterfaceMap) Get(key int) interface{}
- func (gm *IntInterfaceMap) GetOrSet(key int, value interface{}) interface{}
- func (gm *IntInterfaceMap) GetOrSetFunc(key int, f func() interface{}) interface{}
- func (gm *IntInterfaceMap) GetOrSetFuncLock(key int, f func() interface{}) interface{}
- func (gm *IntInterfaceMap) IsEmpty() bool
- func (gm *IntInterfaceMap) Iterator(f func(k int, v interface{}) bool)
- func (gm *IntInterfaceMap) Keys() []int
- func (gm *IntInterfaceMap) LockFunc(f func(m map[int]interface{}))
- func (gm *IntInterfaceMap) Map() map[int]interface{}
- func (gm *IntInterfaceMap) Merge(m *IntInterfaceMap)
- func (gm *IntInterfaceMap) RLockFunc(f func(m map[int]interface{}))
- func (gm *IntInterfaceMap) Remove(key int) interface{}
- func (gm *IntInterfaceMap) Set(key int, val interface{})
- func (gm *IntInterfaceMap) SetIfNotExist(key int, value interface{}) bool
- func (gm *IntInterfaceMap) Size() int
- func (gm *IntInterfaceMap) Values() []interface{}
- type IntStringMap
- func (gm *IntStringMap) BatchRemove(keys []int)
- func (gm *IntStringMap) BatchSet(m map[int]string)
- func (gm *IntStringMap) Clear()
- func (gm *IntStringMap) Clone() *IntStringMap
- func (gm *IntStringMap) Contains(key int) bool
- func (gm *IntStringMap) Flip()
- func (gm *IntStringMap) Get(key int) string
- func (gm *IntStringMap) GetOrSet(key int, value string) string
- func (gm *IntStringMap) GetOrSetFunc(key int, f func() string) string
- func (gm *IntStringMap) GetOrSetFuncLock(key int, f func() string) string
- func (gm *IntStringMap) IsEmpty() bool
- func (gm *IntStringMap) Iterator(f func(k int, v string) bool)
- func (gm *IntStringMap) Keys() []int
- func (gm *IntStringMap) LockFunc(f func(m map[int]string))
- func (gm *IntStringMap) Map() map[int]string
- func (gm *IntStringMap) Merge(m *IntStringMap)
- func (gm *IntStringMap) RLockFunc(f func(m map[int]string))
- func (gm *IntStringMap) Remove(key int) string
- func (gm *IntStringMap) Set(key int, val string)
- func (gm *IntStringMap) SetIfNotExist(key int, value string) bool
- func (gm *IntStringMap) Size() int
- func (gm *IntStringMap) Values() []string
- type Map
- func (gm *Map) BatchRemove(keys []interface{})
- func (gm *Map) BatchSet(m map[interface{}]interface{})
- func (gm *Map) Clear()
- func (gm *Map) Clone() *Map
- func (gm *Map) Contains(key interface{}) bool
- func (gm *Map) Flip()
- func (gm *Map) Get(key interface{}) interface{}
- func (gm *Map) GetOrSet(key interface{}, value interface{}) interface{}
- func (gm *Map) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
- func (gm *Map) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
- func (gm *Map) IsEmpty() bool
- func (gm *Map) Iterator(f func(k interface{}, v interface{}) bool)
- func (gm *Map) Keys() []interface{}
- func (gm *Map) LockFunc(f func(m map[interface{}]interface{}))
- func (gm *Map) Map() map[interface{}]interface{}
- func (gm *Map) Merge(m *Map)
- func (gm *Map) RLockFunc(f func(m map[interface{}]interface{}))
- func (gm *Map) Remove(key interface{}) interface{}
- func (gm *Map) Set(key interface{}, val interface{})
- func (gm *Map) SetIfNotExist(key interface{}, value interface{}) bool
- func (gm *Map) Size() int
- func (gm *Map) Values() []interface{}
- type StringBoolMap
- func (gm *StringBoolMap) BatchRemove(keys []string)
- func (gm *StringBoolMap) BatchSet(m map[string]bool)
- func (gm *StringBoolMap) Clear()
- func (gm *StringBoolMap) Clone() *StringBoolMap
- func (gm *StringBoolMap) Contains(key string) bool
- func (gm *StringBoolMap) Get(key string) bool
- func (gm *StringBoolMap) GetOrSet(key string, value bool) bool
- func (gm *StringBoolMap) GetOrSetFunc(key string, f func() bool) bool
- func (gm *StringBoolMap) GetOrSetFuncLock(key string, f func() bool) bool
- func (gm *StringBoolMap) IsEmpty() bool
- func (gm *StringBoolMap) Iterator(f func(k string, v bool) bool)
- func (gm *StringBoolMap) Keys() []string
- func (gm *StringBoolMap) LockFunc(f func(m map[string]bool))
- func (gm *StringBoolMap) Map() map[string]bool
- func (gm *StringBoolMap) Merge(m *StringBoolMap)
- func (gm *StringBoolMap) RLockFunc(f func(m map[string]bool))
- func (gm *StringBoolMap) Remove(key string) bool
- func (gm *StringBoolMap) Set(key string, val bool)
- func (gm *StringBoolMap) SetIfNotExist(key string, value bool) bool
- func (gm *StringBoolMap) Size() int
- type StringIntMap
- func (gm *StringIntMap) BatchRemove(keys []string)
- func (gm *StringIntMap) BatchSet(m map[string]int)
- func (gm *StringIntMap) Clear()
- func (gm *StringIntMap) Clone() *StringIntMap
- func (gm *StringIntMap) Contains(key string) bool
- func (gm *StringIntMap) Flip()
- func (gm *StringIntMap) Get(key string) int
- func (gm *StringIntMap) GetOrSet(key string, value int) int
- func (gm *StringIntMap) GetOrSetFunc(key string, f func() int) int
- func (gm *StringIntMap) GetOrSetFuncLock(key string, f func() int) int
- func (gm *StringIntMap) IsEmpty() bool
- func (gm *StringIntMap) Iterator(f func(k string, v int) bool)
- func (gm *StringIntMap) Keys() []string
- func (gm *StringIntMap) LockFunc(f func(m map[string]int))
- func (gm *StringIntMap) Map() map[string]int
- func (gm *StringIntMap) Merge(m *StringIntMap)
- func (gm *StringIntMap) RLockFunc(f func(m map[string]int))
- func (gm *StringIntMap) Remove(key string) int
- func (gm *StringIntMap) Set(key string, val int)
- func (gm *StringIntMap) SetIfNotExist(key string, value int) bool
- func (gm *StringIntMap) Size() int
- func (gm *StringIntMap) Values() []int
- type StringInterfaceMap
- func (gm *StringInterfaceMap) BatchRemove(keys []string)
- func (gm *StringInterfaceMap) BatchSet(m map[string]interface{})
- func (gm *StringInterfaceMap) Clear()
- func (gm *StringInterfaceMap) Clone() *StringInterfaceMap
- func (gm *StringInterfaceMap) Contains(key string) bool
- func (gm *StringInterfaceMap) Flip()
- func (gm *StringInterfaceMap) Get(key string) interface{}
- func (gm *StringInterfaceMap) GetOrSet(key string, value interface{}) interface{}
- func (gm *StringInterfaceMap) GetOrSetFunc(key string, f func() interface{}) interface{}
- func (gm *StringInterfaceMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}
- func (gm *StringInterfaceMap) IsEmpty() bool
- func (gm *StringInterfaceMap) Iterator(f func(k string, v interface{}) bool)
- func (gm *StringInterfaceMap) Keys() []string
- func (gm *StringInterfaceMap) LockFunc(f func(m map[string]interface{}))
- func (gm *StringInterfaceMap) Map() map[string]interface{}
- func (gm *StringInterfaceMap) Merge(m *StringInterfaceMap)
- func (gm *StringInterfaceMap) RLockFunc(f func(m map[string]interface{}))
- func (gm *StringInterfaceMap) Remove(key string) interface{}
- func (gm *StringInterfaceMap) Set(key string, val interface{})
- func (gm *StringInterfaceMap) SetIfNotExist(key string, value interface{}) bool
- func (gm *StringInterfaceMap) Size() int
- func (gm *StringInterfaceMap) Values() []interface{}
- type StringStringMap
- func (gm *StringStringMap) BatchRemove(keys []string)
- func (gm *StringStringMap) BatchSet(m map[string]string)
- func (gm *StringStringMap) Clear()
- func (gm *StringStringMap) Clone() *StringStringMap
- func (gm *StringStringMap) Contains(key string) bool
- func (gm *StringStringMap) Flip()
- func (gm *StringStringMap) Get(key string) string
- func (gm *StringStringMap) GetOrSet(key string, value string) string
- func (gm *StringStringMap) GetOrSetFunc(key string, f func() string) string
- func (gm *StringStringMap) GetOrSetFuncLock(key string, f func() string) string
- func (gm *StringStringMap) IsEmpty() bool
- func (gm *StringStringMap) Iterator(f func(k string, v string) bool)
- func (gm *StringStringMap) Keys() []string
- func (gm *StringStringMap) LockFunc(f func(m map[string]string))
- func (gm *StringStringMap) Map() map[string]string
- func (gm *StringStringMap) Merge(m *StringStringMap)
- func (gm *StringStringMap) RLockFunc(f func(m map[string]string))
- func (gm *StringStringMap) Remove(key string) string
- func (gm *StringStringMap) Set(key string, val string)
- func (gm *StringStringMap) SetIfNotExist(key string, value string) bool
- func (gm *StringStringMap) Size() int
- func (gm *StringStringMap) Values() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntBoolMap ¶ added in v1.5.0
type IntBoolMap struct {
// contains filtered or unexported fields
}
func NewIntBoolMap ¶ added in v1.5.0
func NewIntBoolMap(unsafe ...bool) *IntBoolMap
func NewIntBoolMapFrom ¶ added in v1.5.0
func NewIntBoolMapFrom(m map[int]bool, unsafe ...bool) *IntBoolMap
func NewIntBoolMapFromArray ¶ added in v1.5.0
func NewIntBoolMapFromArray(keys []int, values []bool, unsafe ...bool) *IntBoolMap
func (*IntBoolMap) BatchRemove ¶ added in v1.5.0
func (gm *IntBoolMap) BatchRemove(keys []int)
批量删除键值对
func (*IntBoolMap) BatchSet ¶ added in v1.5.0
func (gm *IntBoolMap) BatchSet(m map[int]bool)
批量设置键值对
func (*IntBoolMap) GetOrSet ¶ added in v1.5.0
func (gm *IntBoolMap) GetOrSet(key int, value bool) bool
当键名存在时返回其键值,否则写入指定的键值
func (*IntBoolMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *IntBoolMap) GetOrSetFunc(key int, f func() bool) bool
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*IntBoolMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *IntBoolMap) GetOrSetFuncLock(key int, f func() bool) bool
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*IntBoolMap) Iterator ¶ added in v1.5.0
func (gm *IntBoolMap) Iterator(f func(k int, v bool) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*IntBoolMap) LockFunc ¶ added in v1.5.0
func (gm *IntBoolMap) LockFunc(f func(m map[int]bool))
并发安全锁操作,使用自定义方法执行加锁修改操作
func (*IntBoolMap) RLockFunc ¶ added in v1.5.0
func (gm *IntBoolMap) RLockFunc(f func(m map[int]bool))
并发安全锁操作,使用自定义方法执行加锁读取操作
func (*IntBoolMap) Remove ¶ added in v1.5.0
func (gm *IntBoolMap) Remove(key int) bool
返回对应的键值,并删除该键值
func (*IntBoolMap) SetIfNotExist ¶ added in v1.5.0
func (gm *IntBoolMap) SetIfNotExist(key int, value bool) bool
当键名不存在时写入,并返回true;否则返回false。
type IntIntMap ¶
type IntIntMap struct {
// contains filtered or unexported fields
}
func NewIntIntMap ¶
func NewIntIntMapFromArray ¶ added in v1.5.0
func (*IntIntMap) BatchRemove ¶ added in v1.5.0
批量删除键值对
func (*IntIntMap) GetOrSetFunc ¶
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*IntIntMap) GetOrSetFuncLock ¶
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*IntIntMap) SetIfNotExist ¶
当键名不存在时写入,并返回true;否则返回false。
type IntInterfaceMap ¶ added in v1.5.0
type IntInterfaceMap struct {
// contains filtered or unexported fields
}
func NewIntInterfaceMap ¶ added in v1.5.0
func NewIntInterfaceMap(unsafe ...bool) *IntInterfaceMap
func NewIntInterfaceMapFrom ¶ added in v1.5.0
func NewIntInterfaceMapFrom(m map[int]interface{}, unsafe ...bool) *IntInterfaceMap
func NewIntInterfaceMapFromArray ¶ added in v1.5.0
func NewIntInterfaceMapFromArray(keys []int, values []interface{}, unsafe ...bool) *IntInterfaceMap
func (*IntInterfaceMap) BatchRemove ¶ added in v1.5.0
func (gm *IntInterfaceMap) BatchRemove(keys []int)
批量删除键值对
func (*IntInterfaceMap) BatchSet ¶ added in v1.5.0
func (gm *IntInterfaceMap) BatchSet(m map[int]interface{})
批量设置键值对
func (*IntInterfaceMap) Clone ¶ added in v1.5.0
func (gm *IntInterfaceMap) Clone() *IntInterfaceMap
哈希表克隆.
func (*IntInterfaceMap) Contains ¶ added in v1.5.0
func (gm *IntInterfaceMap) Contains(key int) bool
是否存在某个键
func (*IntInterfaceMap) Get ¶ added in v1.5.0
func (gm *IntInterfaceMap) Get(key int) interface{}
获取键值
func (*IntInterfaceMap) GetOrSet ¶ added in v1.5.0
func (gm *IntInterfaceMap) GetOrSet(key int, value interface{}) interface{}
当键名存在时返回其键值,否则写入指定的键值
func (*IntInterfaceMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *IntInterfaceMap) GetOrSetFunc(key int, f func() interface{}) interface{}
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*IntInterfaceMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *IntInterfaceMap) GetOrSetFuncLock(key int, f func() interface{}) interface{}
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*IntInterfaceMap) Iterator ¶ added in v1.5.0
func (gm *IntInterfaceMap) Iterator(f func(k int, v interface{}) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*IntInterfaceMap) LockFunc ¶ added in v1.5.0
func (gm *IntInterfaceMap) LockFunc(f func(m map[int]interface{}))
并发安全锁操作,使用自定义方法执行加锁修改操作
func (*IntInterfaceMap) Map ¶ added in v1.5.0
func (gm *IntInterfaceMap) Map() map[int]interface{}
返回当前哈希表的数据Map.
func (*IntInterfaceMap) Merge ¶ added in v1.5.0
func (gm *IntInterfaceMap) Merge(m *IntInterfaceMap)
合并两个Map.
func (*IntInterfaceMap) RLockFunc ¶ added in v1.5.0
func (gm *IntInterfaceMap) RLockFunc(f func(m map[int]interface{}))
并发安全锁操作,使用自定义方法执行加锁读取操作
func (*IntInterfaceMap) Remove ¶ added in v1.5.0
func (gm *IntInterfaceMap) Remove(key int) interface{}
返回对应的键值,并删除该键值
func (*IntInterfaceMap) Set ¶ added in v1.5.0
func (gm *IntInterfaceMap) Set(key int, val interface{})
设置键值对
func (*IntInterfaceMap) SetIfNotExist ¶ added in v1.5.0
func (gm *IntInterfaceMap) SetIfNotExist(key int, value interface{}) bool
当键名不存在时写入,并返回true;否则返回false。
func (*IntInterfaceMap) Values ¶ added in v1.5.0
func (gm *IntInterfaceMap) Values() []interface{}
返回值列表(注意是随机排序)
type IntStringMap ¶ added in v1.5.0
type IntStringMap struct {
// contains filtered or unexported fields
}
func NewIntStringMap ¶ added in v1.5.0
func NewIntStringMap(unsafe ...bool) *IntStringMap
func NewIntStringMapFrom ¶ added in v1.5.0
func NewIntStringMapFrom(m map[int]string, unsafe ...bool) *IntStringMap
func NewIntStringMapFromArray ¶ added in v1.5.0
func NewIntStringMapFromArray(keys []int, values []string, unsafe ...bool) *IntStringMap
func (*IntStringMap) BatchRemove ¶ added in v1.5.0
func (gm *IntStringMap) BatchRemove(keys []int)
批量删除键值对
func (*IntStringMap) BatchSet ¶ added in v1.5.0
func (gm *IntStringMap) BatchSet(m map[int]string)
批量设置键值对
func (*IntStringMap) Contains ¶ added in v1.5.0
func (gm *IntStringMap) Contains(key int) bool
是否存在某个键
func (*IntStringMap) GetOrSet ¶ added in v1.5.0
func (gm *IntStringMap) GetOrSet(key int, value string) string
当键名存在时返回其键值,否则写入指定的键值
func (*IntStringMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *IntStringMap) GetOrSetFunc(key int, f func() string) string
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*IntStringMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *IntStringMap) GetOrSetFuncLock(key int, f func() string) string
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*IntStringMap) Iterator ¶ added in v1.5.0
func (gm *IntStringMap) Iterator(f func(k int, v string) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*IntStringMap) LockFunc ¶ added in v1.5.0
func (gm *IntStringMap) LockFunc(f func(m map[int]string))
并发安全锁操作,使用自定义方法执行加锁修改操作
func (*IntStringMap) Map ¶ added in v1.5.0
func (gm *IntStringMap) Map() map[int]string
返回当前哈希表的数据Map.
func (*IntStringMap) Merge ¶ added in v1.5.0
func (gm *IntStringMap) Merge(m *IntStringMap)
合并两个Map.
func (*IntStringMap) RLockFunc ¶ added in v1.5.0
func (gm *IntStringMap) RLockFunc(f func(m map[int]string))
并发安全锁操作,使用自定义方法执行加锁读取操作
func (*IntStringMap) Remove ¶ added in v1.5.0
func (gm *IntStringMap) Remove(key int) string
返回对应的键值,并删除该键值
func (*IntStringMap) SetIfNotExist ¶ added in v1.5.0
func (gm *IntStringMap) SetIfNotExist(key int, value string) bool
当键名不存在时写入,并返回true;否则返回false。
func (*IntStringMap) Values ¶ added in v1.5.0
func (gm *IntStringMap) Values() []string
返回值列表(注意是随机排序)
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
注意: 1、这个Map是所有并发安全Map中效率最低的,如果对效率要求比较高的场合,请合理选择对应数据类型的Map; 2、这个Map的优点是使用简便,由于键值都是interface{}类型,因此对键值的数据类型要求不高; 3、底层实现比较类似于sync.Map;
func New ¶
Create an empty hash map. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe in default.
创建一个空的哈希表,参数unsafe用于指定是否用于非并发安全场景,默认为false,表示并发安全。
func NewFrom ¶
Create a hash map from given map. Be aware that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
基于给定的map变量创建哈希表对象,注意由于map是指针类型,外部对map有操作时会有并发安全问题。
func NewFromArray ¶ added in v1.5.0
Create a hash map from given arrays. The param <keys> given as the keys of the map, and <values> as the corresponding values.
基于给定的数组变量创建哈希表对象,keys作为键名, values作为键值。 当keys数组大小比values数组大时,多余的键名将会使用对应类型默认的键值。
func (*Map) BatchRemove ¶ added in v1.5.0
func (gm *Map) BatchRemove(keys []interface{})
Batch remove by keys.
批量删除键值对
func (*Map) BatchSet ¶ added in v1.5.0
func (gm *Map) BatchSet(m map[interface{}]interface{})
Batch set key-values to the hash map.
批量设置键值对
func (*Map) Clear ¶ added in v1.5.0
func (gm *Map) Clear()
Clear the hash map, it will remake a new underlying map data map.
清空哈希表
func (*Map) Clone ¶ added in v1.5.0
Clone current hash map with copy of underlying data, return a new hash map.
哈希表克隆.
func (*Map) Flip ¶ added in v1.5.0
func (gm *Map) Flip()
Exchange key-value in the hash map, it will change key-value to value-key.
交换Map中的键和值.
func (*Map) Get ¶ added in v1.5.0
func (gm *Map) Get(key interface{}) interface{}
Get value by key.
获取键值
func (*Map) GetOrSet ¶ added in v1.5.0
func (gm *Map) GetOrSet(key interface{}, value interface{}) interface{}
Get the value by key, or set it with given key-value if not exist.
当键名存在时返回其键值,否则写入指定的键值
func (*Map) GetOrSetFunc ¶ added in v1.5.0
func (gm *Map) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
Get the value by key, or set the it with return of callback function <f> if not exist.
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*Map) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *Map) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
Get the value by key, or set the it with return of callback function <f> if not exist. The difference with GetOrSetFunc is, it locks in executing callback function <f>.
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*Map) Iterator ¶ added in v1.5.0
Iterate the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*Map) Keys ¶ added in v1.5.0
func (gm *Map) Keys() []interface{}
Return all the keys of hash map as a slice.
返回键列表.
func (*Map) LockFunc ¶ added in v1.5.0
func (gm *Map) LockFunc(f func(m map[interface{}]interface{}))
Lock writing with given callback <f>.
并发安全锁操作,使用自定义方法执行加锁修改操作
func (*Map) Map ¶ added in v1.5.0
func (gm *Map) Map() map[interface{}]interface{}
Returns copy of the data of the hash map.
返回当前哈希表的数据Map.
func (*Map) RLockFunc ¶ added in v1.5.0
func (gm *Map) RLockFunc(f func(m map[interface{}]interface{}))
Lock reading with given callback <f>.
并发安全锁操作,使用自定义方法执行加锁读取操作
func (*Map) Remove ¶ added in v1.5.0
func (gm *Map) Remove(key interface{}) interface{}
Remove by given key.
返回对应的键值,并删除该键值
func (*Map) Set ¶ added in v1.5.0
func (gm *Map) Set(key interface{}, val interface{})
Set key-value to the hash map.
设置键值对
func (*Map) SetIfNotExist ¶ added in v1.5.0
Set key-value if the key does not exist, then return true; or else return false.
当键名不存在时写入,并返回true;否则返回false。
type StringBoolMap ¶ added in v1.5.0
type StringBoolMap struct {
// contains filtered or unexported fields
}
func NewStringBoolMap ¶ added in v1.5.0
func NewStringBoolMap(unsafe ...bool) *StringBoolMap
func NewStringBoolMapFrom ¶ added in v1.5.0
func NewStringBoolMapFrom(m map[string]bool, unsafe ...bool) *StringBoolMap
func NewStringBoolMapFromArray ¶ added in v1.5.0
func NewStringBoolMapFromArray(keys []string, values []bool, unsafe ...bool) *StringBoolMap
func (*StringBoolMap) BatchRemove ¶ added in v1.5.0
func (gm *StringBoolMap) BatchRemove(keys []string)
批量删除键值对
func (*StringBoolMap) BatchSet ¶ added in v1.5.0
func (gm *StringBoolMap) BatchSet(m map[string]bool)
批量设置键值对
func (*StringBoolMap) Clone ¶ added in v1.5.0
func (gm *StringBoolMap) Clone() *StringBoolMap
哈希表克隆.
func (*StringBoolMap) Contains ¶ added in v1.5.0
func (gm *StringBoolMap) Contains(key string) bool
是否存在某个键
func (*StringBoolMap) GetOrSet ¶ added in v1.5.0
func (gm *StringBoolMap) GetOrSet(key string, value bool) bool
当键名存在时返回其键值,否则写入指定的键值
func (*StringBoolMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringBoolMap) GetOrSetFunc(key string, f func() bool) bool
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*StringBoolMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringBoolMap) GetOrSetFuncLock(key string, f func() bool) bool
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*StringBoolMap) Iterator ¶ added in v1.5.0
func (gm *StringBoolMap) Iterator(f func(k string, v bool) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*StringBoolMap) LockFunc ¶ added in v1.5.0
func (gm *StringBoolMap) LockFunc(f func(m map[string]bool))
并发安全锁操作,使用自定义方法执行加锁修改操作
func (*StringBoolMap) Map ¶ added in v1.5.0
func (gm *StringBoolMap) Map() map[string]bool
返回当前哈希表的数据Map.
func (*StringBoolMap) Merge ¶ added in v1.5.0
func (gm *StringBoolMap) Merge(m *StringBoolMap)
合并两个Map.
func (*StringBoolMap) RLockFunc ¶ added in v1.5.0
func (gm *StringBoolMap) RLockFunc(f func(m map[string]bool))
并发安全锁操作,使用自定义方法执行加锁读取操作
func (*StringBoolMap) Remove ¶ added in v1.5.0
func (gm *StringBoolMap) Remove(key string) bool
返回对应的键值,并删除该键值
func (*StringBoolMap) Set ¶ added in v1.5.0
func (gm *StringBoolMap) Set(key string, val bool)
设置键值对
func (*StringBoolMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringBoolMap) SetIfNotExist(key string, value bool) bool
当键名不存在时写入,并返回true;否则返回false。
type StringIntMap ¶ added in v1.5.0
type StringIntMap struct {
// contains filtered or unexported fields
}
func NewStringIntMap ¶ added in v1.5.0
func NewStringIntMap(unsafe ...bool) *StringIntMap
func NewStringIntMapFrom ¶ added in v1.5.0
func NewStringIntMapFrom(m map[string]int, unsafe ...bool) *StringIntMap
func NewStringIntMapFromArray ¶ added in v1.5.0
func NewStringIntMapFromArray(keys []string, values []int, unsafe ...bool) *StringIntMap
func (*StringIntMap) BatchRemove ¶ added in v1.5.0
func (gm *StringIntMap) BatchRemove(keys []string)
批量删除键值对
func (*StringIntMap) BatchSet ¶ added in v1.5.0
func (gm *StringIntMap) BatchSet(m map[string]int)
批量设置键值对
func (*StringIntMap) Contains ¶ added in v1.5.0
func (gm *StringIntMap) Contains(key string) bool
是否存在某个键
func (*StringIntMap) GetOrSet ¶ added in v1.5.0
func (gm *StringIntMap) GetOrSet(key string, value int) int
当键名存在时返回其键值,否则写入指定的键值
func (*StringIntMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringIntMap) GetOrSetFunc(key string, f func() int) int
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*StringIntMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringIntMap) GetOrSetFuncLock(key string, f func() int) int
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*StringIntMap) Iterator ¶ added in v1.5.0
func (gm *StringIntMap) Iterator(f func(k string, v int) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*StringIntMap) LockFunc ¶ added in v1.5.0
func (gm *StringIntMap) LockFunc(f func(m map[string]int))
并发安全写锁操作,使用自定义方法执行加锁修改操作
func (*StringIntMap) Map ¶ added in v1.5.0
func (gm *StringIntMap) Map() map[string]int
返回当前哈希表的数据Map.
func (*StringIntMap) Merge ¶ added in v1.5.0
func (gm *StringIntMap) Merge(m *StringIntMap)
合并两个Map.
func (*StringIntMap) RLockFunc ¶ added in v1.5.0
func (gm *StringIntMap) RLockFunc(f func(m map[string]int))
并发安全读锁操作,使用自定义方法执行加锁读取操作
func (*StringIntMap) Remove ¶ added in v1.5.0
func (gm *StringIntMap) Remove(key string) int
返回对应的键值,并删除该键值
func (*StringIntMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringIntMap) SetIfNotExist(key string, value int) bool
当键名不存在时写入,并返回true;否则返回false。
type StringInterfaceMap ¶ added in v1.5.0
type StringInterfaceMap struct {
// contains filtered or unexported fields
}
func NewStringInterfaceMap ¶ added in v1.5.0
func NewStringInterfaceMap(unsafe ...bool) *StringInterfaceMap
func NewStringInterfaceMapFrom ¶ added in v1.5.0
func NewStringInterfaceMapFrom(m map[string]interface{}, unsafe ...bool) *StringInterfaceMap
func NewStringInterfaceMapFromArray ¶ added in v1.5.0
func NewStringInterfaceMapFromArray(keys []string, values []interface{}, unsafe ...bool) *StringInterfaceMap
func (*StringInterfaceMap) BatchRemove ¶ added in v1.5.0
func (gm *StringInterfaceMap) BatchRemove(keys []string)
批量删除键值对
func (*StringInterfaceMap) BatchSet ¶ added in v1.5.0
func (gm *StringInterfaceMap) BatchSet(m map[string]interface{})
批量设置键值对
func (*StringInterfaceMap) Clone ¶ added in v1.5.0
func (gm *StringInterfaceMap) Clone() *StringInterfaceMap
哈希表克隆.
func (*StringInterfaceMap) Contains ¶ added in v1.5.0
func (gm *StringInterfaceMap) Contains(key string) bool
是否存在某个键
func (*StringInterfaceMap) Get ¶ added in v1.5.0
func (gm *StringInterfaceMap) Get(key string) interface{}
获取键值
func (*StringInterfaceMap) GetOrSet ¶ added in v1.5.0
func (gm *StringInterfaceMap) GetOrSet(key string, value interface{}) interface{}
当键名存在时返回其键值,否则写入指定的键值
func (*StringInterfaceMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringInterfaceMap) GetOrSetFunc(key string, f func() interface{}) interface{}
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*StringInterfaceMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringInterfaceMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*StringInterfaceMap) IsEmpty ¶ added in v1.5.0
func (gm *StringInterfaceMap) IsEmpty() bool
哈希表是否为空
func (*StringInterfaceMap) Iterator ¶ added in v1.5.0
func (gm *StringInterfaceMap) Iterator(f func(k string, v interface{}) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*StringInterfaceMap) Keys ¶ added in v1.5.0
func (gm *StringInterfaceMap) Keys() []string
返回键列表
func (*StringInterfaceMap) LockFunc ¶ added in v1.5.0
func (gm *StringInterfaceMap) LockFunc(f func(m map[string]interface{}))
并发安全写锁操作,使用自定义方法执行加锁修改操作
func (*StringInterfaceMap) Map ¶ added in v1.5.0
func (gm *StringInterfaceMap) Map() map[string]interface{}
返回当前哈希表的数据Map.
func (*StringInterfaceMap) Merge ¶ added in v1.5.0
func (gm *StringInterfaceMap) Merge(m *StringInterfaceMap)
合并两个Map.
func (*StringInterfaceMap) RLockFunc ¶ added in v1.5.0
func (gm *StringInterfaceMap) RLockFunc(f func(m map[string]interface{}))
并发安全读锁操作,使用自定义方法执行加锁读取操作
func (*StringInterfaceMap) Remove ¶ added in v1.5.0
func (gm *StringInterfaceMap) Remove(key string) interface{}
返回对应的键值,并删除该键值
func (*StringInterfaceMap) Set ¶ added in v1.5.0
func (gm *StringInterfaceMap) Set(key string, val interface{})
设置键值对
func (*StringInterfaceMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringInterfaceMap) SetIfNotExist(key string, value interface{}) bool
当键名不存在时写入,并返回true;否则返回false。
func (*StringInterfaceMap) Values ¶ added in v1.5.0
func (gm *StringInterfaceMap) Values() []interface{}
返回值列表(注意是随机排序)
type StringStringMap ¶ added in v1.5.0
type StringStringMap struct {
// contains filtered or unexported fields
}
func NewStringStringMap ¶ added in v1.5.0
func NewStringStringMap(unsafe ...bool) *StringStringMap
func NewStringStringMapFrom ¶ added in v1.5.0
func NewStringStringMapFrom(m map[string]string, unsafe ...bool) *StringStringMap
func NewStringStringMapFromArray ¶ added in v1.5.0
func NewStringStringMapFromArray(keys []string, values []string, unsafe ...bool) *StringStringMap
func (*StringStringMap) BatchRemove ¶ added in v1.5.0
func (gm *StringStringMap) BatchRemove(keys []string)
批量删除键值对
func (*StringStringMap) BatchSet ¶ added in v1.5.0
func (gm *StringStringMap) BatchSet(m map[string]string)
批量设置键值对
func (*StringStringMap) Clone ¶ added in v1.5.0
func (gm *StringStringMap) Clone() *StringStringMap
哈希表克隆.
func (*StringStringMap) Contains ¶ added in v1.5.0
func (gm *StringStringMap) Contains(key string) bool
是否存在某个键
func (*StringStringMap) Get ¶ added in v1.5.0
func (gm *StringStringMap) Get(key string) string
获取键值
func (*StringStringMap) GetOrSet ¶ added in v1.5.0
func (gm *StringStringMap) GetOrSet(key string, value string) string
当键名存在时返回其键值,否则写入指定的键值
func (*StringStringMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringStringMap) GetOrSetFunc(key string, f func() string) string
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (*StringStringMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringStringMap) GetOrSetFuncLock(key string, f func() string) string
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (*StringStringMap) Iterator ¶ added in v1.5.0
func (gm *StringStringMap) Iterator(f func(k string, v string) bool)
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历
func (*StringStringMap) LockFunc ¶ added in v1.5.0
func (gm *StringStringMap) LockFunc(f func(m map[string]string))
并发安全写锁操作,使用自定义方法执行加锁修改操作
func (*StringStringMap) Map ¶ added in v1.5.0
func (gm *StringStringMap) Map() map[string]string
返回当前哈希表的数据Map.
func (*StringStringMap) Merge ¶ added in v1.5.0
func (gm *StringStringMap) Merge(m *StringStringMap)
合并两个Map.
func (*StringStringMap) RLockFunc ¶ added in v1.5.0
func (gm *StringStringMap) RLockFunc(f func(m map[string]string))
并发安全读锁操作,使用自定义方法执行加锁读取操作
func (*StringStringMap) Remove ¶ added in v1.5.0
func (gm *StringStringMap) Remove(key string) string
返回对应的键值,并删除该键值
func (*StringStringMap) Set ¶ added in v1.5.0
func (gm *StringStringMap) Set(key string, val string)
设置键值对
func (*StringStringMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringStringMap) SetIfNotExist(key string, value string) bool
当键名不存在时写入,并返回true;否则返回false。
func (*StringStringMap) Values ¶ added in v1.5.0
func (gm *StringStringMap) Values() []string
返回值列表(注意是随机排序)