Documentation ¶
Index ¶
- type AnyAnyMap
- func (that *AnyAnyMap) Clear()
- func (that *AnyAnyMap) Clone(safe ...bool) *AnyAnyMap
- func (that *AnyAnyMap) Contains(key interface{}) bool
- func (that *AnyAnyMap) FilterEmpty()
- func (that *AnyAnyMap) FilterNil()
- func (that *AnyAnyMap) Flip()
- func (that *AnyAnyMap) Get(key interface{}) (value interface{})
- func (that *AnyAnyMap) GetOrSet(key interface{}, value interface{}) interface{}
- func (that *AnyAnyMap) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
- func (that *AnyAnyMap) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
- func (that *AnyAnyMap) IsEmpty() bool
- func (that *AnyAnyMap) Iterator(f func(k interface{}, v interface{}) bool)
- func (that *AnyAnyMap) Keys() []interface{}
- func (that *AnyAnyMap) LockFunc(f func(m map[interface{}]interface{}))
- func (that *AnyAnyMap) Map() map[interface{}]interface{}
- func (that *AnyAnyMap) MapCopy() map[interface{}]interface{}
- func (that *AnyAnyMap) MarshalJSON() ([]byte, error)
- func (that *AnyAnyMap) Merge(other *AnyAnyMap)
- func (that *AnyAnyMap) Pop() (key, value interface{})
- func (that *AnyAnyMap) Pops(size int) map[interface{}]interface{}
- func (that *AnyAnyMap) RLockFunc(f func(m map[interface{}]interface{}))
- func (that *AnyAnyMap) Random() (key, value interface{}, exist bool)
- func (that *AnyAnyMap) Remove(key interface{}) (value interface{})
- func (that *AnyAnyMap) Removes(keys []interface{})
- func (that *AnyAnyMap) Replace(data map[interface{}]interface{})
- func (that *AnyAnyMap) Search(key interface{}) (value interface{}, found bool)
- func (that *AnyAnyMap) Set(key interface{}, value interface{})
- func (that *AnyAnyMap) SetIfNotExist(key interface{}, value interface{}) bool
- func (that *AnyAnyMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool
- func (that *AnyAnyMap) SetIfNotExistFuncLock(key interface{}, f func() interface{}) bool
- func (that *AnyAnyMap) Sets(data map[interface{}]interface{})
- func (that *AnyAnyMap) Size() int
- func (that *AnyAnyMap) String() string
- func (that *AnyAnyMap) UnmarshalJSON(b []byte) error
- func (that *AnyAnyMap) UnmarshalValue(value interface{}) (err error)
- func (that *AnyAnyMap) Values() []interface{}
- type HashMap
- type IntAnyMap
- func (that *IntAnyMap) Clear()
- func (that *IntAnyMap) Clone() *IntAnyMap
- func (that *IntAnyMap) Contains(key int) bool
- func (that *IntAnyMap) FilterEmpty()
- func (that *IntAnyMap) FilterNil()
- func (that *IntAnyMap) Flip()
- func (that *IntAnyMap) Get(key int) (value interface{})
- func (that *IntAnyMap) GetOrSet(key int, value interface{}) interface{}
- func (that *IntAnyMap) GetOrSetFunc(key int, f func() interface{}) interface{}
- func (that *IntAnyMap) GetOrSetFuncLock(key int, f func() interface{}) interface{}
- func (that *IntAnyMap) GetVar(key int) *gvar.Var
- func (that *IntAnyMap) GetVarOrSet(key int, value interface{}) *gvar.Var
- func (that *IntAnyMap) GetVarOrSetFunc(key int, f func() interface{}) *gvar.Var
- func (that *IntAnyMap) GetVarOrSetFuncLock(key int, f func() interface{}) *gvar.Var
- func (that *IntAnyMap) IsEmpty() bool
- func (that *IntAnyMap) Iterator(f func(k int, v interface{}) bool)
- func (that *IntAnyMap) Keys() []int
- func (that *IntAnyMap) LockFunc(f func(m map[int]interface{}))
- func (that *IntAnyMap) Map() map[int]interface{}
- func (that *IntAnyMap) MapCopy() map[int]interface{}
- func (that *IntAnyMap) MapStrAny() map[string]interface{}
- func (that *IntAnyMap) MarshalJSON() ([]byte, error)
- func (that *IntAnyMap) Merge(other *IntAnyMap)
- func (that *IntAnyMap) Pop() (key int, value interface{})
- func (that *IntAnyMap) Pops(size int) map[int]interface{}
- func (that *IntAnyMap) RLockFunc(f func(m map[int]interface{}))
- func (that *IntAnyMap) Remove(key int) (value interface{})
- func (that *IntAnyMap) Removes(keys []int)
- func (that *IntAnyMap) Replace(data map[int]interface{})
- func (that *IntAnyMap) Search(key int) (value interface{}, found bool)
- func (that *IntAnyMap) Set(key int, val interface{})
- func (that *IntAnyMap) SetIfNotExist(key int, value interface{}) bool
- func (that *IntAnyMap) SetIfNotExistFunc(key int, f func() interface{}) bool
- func (that *IntAnyMap) SetIfNotExistFuncLock(key int, f func() interface{}) bool
- func (that *IntAnyMap) Sets(data map[int]interface{})
- func (that *IntAnyMap) Size() int
- func (that *IntAnyMap) String() string
- func (that *IntAnyMap) UnmarshalJSON(b []byte) error
- func (that *IntAnyMap) UnmarshalValue(value interface{}) (err error)
- func (that *IntAnyMap) Values() []interface{}
- type Map
- type StrAnyMap
- func (that *StrAnyMap) Clear()
- func (that *StrAnyMap) Clone() *StrAnyMap
- func (that *StrAnyMap) Contains(key string) bool
- func (that *StrAnyMap) FilterEmpty()
- func (that *StrAnyMap) FilterNil()
- func (that *StrAnyMap) Flip()
- func (that *StrAnyMap) Get(key string) (value interface{})
- func (that *StrAnyMap) GetOrSet(key string, value interface{}) interface{}
- func (that *StrAnyMap) GetOrSetFunc(key string, f func() interface{}) interface{}
- func (that *StrAnyMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}
- func (that *StrAnyMap) GetVar(key string) *dvar.Var
- func (that *StrAnyMap) GetVarOrSet(key string, value interface{}) *dvar.Var
- func (that *StrAnyMap) GetVarOrSetFunc(key string, f func() interface{}) *dvar.Var
- func (that *StrAnyMap) GetVarOrSetFuncLock(key string, f func() interface{}) *dvar.Var
- func (that *StrAnyMap) IsEmpty() bool
- func (that *StrAnyMap) Iterator(f func(k string, v interface{}) bool)
- func (that *StrAnyMap) Keys() []string
- func (that *StrAnyMap) LockFunc(f func(m map[string]interface{}))
- func (that *StrAnyMap) Map() map[string]interface{}
- func (that *StrAnyMap) MapCopy() map[string]interface{}
- func (that *StrAnyMap) MapStrAny() map[string]interface{}
- func (that *StrAnyMap) MarshalJSON() ([]byte, error)
- func (that *StrAnyMap) Merge(other *StrAnyMap)
- func (that *StrAnyMap) Pop() (key string, value interface{})
- func (that *StrAnyMap) Pops(size int) map[string]interface{}
- func (that *StrAnyMap) RLockFunc(f func(m map[string]interface{}))
- func (that *StrAnyMap) Remove(key string) (value interface{})
- func (that *StrAnyMap) Removes(keys []string)
- func (that *StrAnyMap) Replace(data map[string]interface{})
- func (that *StrAnyMap) Search(key string) (value interface{}, found bool)
- func (that *StrAnyMap) Set(key string, val interface{})
- func (that *StrAnyMap) SetIfNotExist(key string, value interface{}) bool
- func (that *StrAnyMap) SetIfNotExistFunc(key string, f func() interface{}) bool
- func (that *StrAnyMap) SetIfNotExistFuncLock(key string, f func() interface{}) bool
- func (that *StrAnyMap) Sets(data map[string]interface{})
- func (that *StrAnyMap) Size() int
- func (that *StrAnyMap) String() string
- func (that *StrAnyMap) UnmarshalJSON(b []byte) error
- func (that *StrAnyMap) UnmarshalValue(value interface{}) (err error)
- func (that *StrAnyMap) Values() []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyAnyMap ¶
type AnyAnyMap struct {
// contains filtered or unexported fields
}
AnyAnyMap 并发安全的hash字典表
func NewAnyAnyMapFrom ¶
NewAnyAnyMapFrom 通过map创建hash表
func (*AnyAnyMap) GetOrSet ¶
func (that *AnyAnyMap) GetOrSet(key interface{}, value interface{}) interface{}
GetOrSet 查找key对应的值是否存在,如果未找到,则写入
func (*AnyAnyMap) GetOrSetFunc ¶
func (that *AnyAnyMap) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
GetOrSetFunc 获取指定key的值,如果不存在,则通过方法f生成该值,并写入到map,然后返回 生成新值的方法未使用到锁,不会造成阻塞
func (*AnyAnyMap) GetOrSetFuncLock ¶
func (that *AnyAnyMap) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
GetOrSetFuncLock 与上面GetOrSetFunc方法的区别,在乎生成值的时候是否使用锁,此方法生成值的时候会使用到做,传入的方法不能阻塞, 不然会造成map加锁不可读写
func (*AnyAnyMap) LockFunc ¶
func (that *AnyAnyMap) LockFunc(f func(m map[interface{}]interface{}))
LockFunc 加锁执行方法操作数据
func (*AnyAnyMap) MapCopy ¶
func (that *AnyAnyMap) MapCopy() map[interface{}]interface{}
MapCopy copy一份map数据
func (*AnyAnyMap) MarshalJSON ¶
MarshalJSON json序列化
func (*AnyAnyMap) RLockFunc ¶
func (that *AnyAnyMap) RLockFunc(f func(m map[interface{}]interface{}))
RLockFunc 加读锁执行方法操作数据
func (*AnyAnyMap) Remove ¶
func (that *AnyAnyMap) Remove(key interface{}) (value interface{})
Remove 移除指定的key,并返回它对应的值
func (*AnyAnyMap) Replace ¶
func (that *AnyAnyMap) Replace(data map[interface{}]interface{})
Replace 替换map
func (*AnyAnyMap) Set ¶
func (that *AnyAnyMap) Set(key interface{}, value interface{})
Set 设置key value
func (*AnyAnyMap) SetIfNotExist ¶
SetIfNotExist 如果map中不存在该key,则设置
func (*AnyAnyMap) SetIfNotExistFunc ¶
SetIfNotExistFunc 如果map中不存在key,则调用方法f生成,生成的时候未加锁
func (*AnyAnyMap) SetIfNotExistFuncLock ¶
SetIfNotExistFuncLock 如果map中不存在key,则调用方法f生成,生成的时候加锁
func (*AnyAnyMap) UnmarshalJSON ¶
UnmarshalJSON json反序列化
func (*AnyAnyMap) UnmarshalValue ¶
type IntAnyMap ¶ added in v0.0.5
type IntAnyMap struct {
// contains filtered or unexported fields
}
func NewIntAnyMap ¶ added in v0.0.5
NewIntAnyMap 创建key值为int类型的hash表
func NewIntAnyMapFrom ¶ added in v0.0.5
NewIntAnyMapFrom 通过基础数据格式创建map
func (*IntAnyMap) Clear ¶ added in v0.0.5
func (that *IntAnyMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*IntAnyMap) Contains ¶ added in v0.0.5
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntAnyMap) FilterEmpty ¶ added in v0.0.5
func (that *IntAnyMap) FilterEmpty()
FilterEmpty 删除空值
func (*IntAnyMap) Flip ¶ added in v0.0.5
func (that *IntAnyMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*IntAnyMap) GetOrSet ¶ added in v0.0.5
GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.
func (*IntAnyMap) GetOrSetFunc ¶ added in v0.0.5
GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.
func (*IntAnyMap) GetOrSetFuncLock ¶ added in v0.0.5
GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.
GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.
func (*IntAnyMap) GetVar ¶ added in v0.0.5
GetVar returns a Var with the value by given <key>. The returned Var is un-concurrent safe.
func (*IntAnyMap) GetVarOrSet ¶ added in v0.0.5
GetVarOrSet returns a Var with result from GetVarOrSet. The returned Var is un-concurrent safe.
func (*IntAnyMap) GetVarOrSetFunc ¶ added in v0.0.5
GetVarOrSetFunc returns a Var with result from GetOrSetFunc. The returned Var is un-concurrent safe.
func (*IntAnyMap) GetVarOrSetFuncLock ¶ added in v0.0.5
GetVarOrSetFuncLock returns a Var with result from GetOrSetFuncLock. The returned Var is un-concurrent safe.
func (*IntAnyMap) IsEmpty ¶ added in v0.0.5
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntAnyMap) LockFunc ¶ added in v0.0.5
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*IntAnyMap) MarshalJSON ¶ added in v0.0.5
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*IntAnyMap) Merge ¶ added in v0.0.5
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*IntAnyMap) Pops ¶ added in v0.0.5
Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.
func (*IntAnyMap) RLockFunc ¶ added in v0.0.5
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*IntAnyMap) Remove ¶ added in v0.0.5
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntAnyMap) SetIfNotExist ¶ added in v0.0.5
SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.
func (*IntAnyMap) SetIfNotExistFunc ¶ added in v0.0.5
SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.
func (*IntAnyMap) SetIfNotExistFuncLock ¶ added in v0.0.5
SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.
SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.
func (*IntAnyMap) UnmarshalJSON ¶ added in v0.0.5
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*IntAnyMap) UnmarshalValue ¶ added in v0.0.5
UnmarshalValue is an interface implement which sets any type of value for map.
type Map ¶
type Map = AnyAnyMap // Map is alias of AnyAnyMap.
func NewHashMapFrom ¶
NewHashMapFrom 创建一个map对象,并把参数data作为值
type StrAnyMap ¶ added in v0.0.3
type StrAnyMap struct {
// contains filtered or unexported fields
}
func NewStrAnyMap ¶ added in v0.0.3
NewStrAnyMap 返回一个空的StrAnyMap对象
func NewStrAnyMapFrom ¶ added in v0.0.3
NewStrAnyMapFrom 从给定的map 创建并返回一个哈希映射。 注意,param map将被设置为底层数据map(没有深层复制), 当改变外部映射时,可能会有一些并发安全问题。
func (*StrAnyMap) Clear ¶ added in v0.0.3
func (that *StrAnyMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*StrAnyMap) Contains ¶ added in v0.0.3
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StrAnyMap) FilterEmpty ¶ added in v0.0.3
func (that *StrAnyMap) FilterEmpty()
FilterEmpty 删除map对象中的空值 空值的定义: 0, nil, false, "", len(slice/map/chan) == 0
func (*StrAnyMap) FilterNil ¶ added in v0.0.3
func (that *StrAnyMap) FilterNil()
FilterNil 删除map中值为 nil的对象
func (*StrAnyMap) Flip ¶ added in v0.0.3
func (that *StrAnyMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*StrAnyMap) GetOrSetFunc ¶ added in v0.0.3
GetOrSetFunc 如果存在,则返回,不存在则设置并返回
func (*StrAnyMap) GetOrSetFuncLock ¶ added in v0.0.3
GetOrSetFuncLock 如果存在,则返回,不存在则设置并返回
func (*StrAnyMap) GetVarOrSet ¶ added in v0.0.3
GetVarOrSet returns a Var with result from GetVarOrSet. The returned Var is un-concurrent safe.
func (*StrAnyMap) GetVarOrSetFunc ¶ added in v0.0.3
GetVarOrSetFunc returns a Var with result from GetOrSetFunc. The returned Var is un-concurrent safe.
func (*StrAnyMap) GetVarOrSetFuncLock ¶ added in v0.0.3
GetVarOrSetFuncLock returns a Var with result from GetOrSetFuncLock. The returned Var is un-concurrent safe.
func (*StrAnyMap) IsEmpty ¶ added in v0.0.3
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StrAnyMap) LockFunc ¶ added in v0.0.3
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*StrAnyMap) MarshalJSON ¶ added in v0.0.3
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*StrAnyMap) Merge ¶ added in v0.0.3
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*StrAnyMap) RLockFunc ¶ added in v0.0.3
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*StrAnyMap) Remove ¶ added in v0.0.3
Remove deletes value from map by given <key>, and return this deleted value.
func (*StrAnyMap) Search ¶ added in v0.0.3
Search 查找key是否存在map中,知道则返回该值,found为true,没有找到value=nil,found=false
func (*StrAnyMap) SetIfNotExist ¶ added in v0.0.3
SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.
func (*StrAnyMap) SetIfNotExistFunc ¶ added in v0.0.3
SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.
func (*StrAnyMap) SetIfNotExistFuncLock ¶ added in v0.0.3
SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.
SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.
func (*StrAnyMap) UnmarshalJSON ¶ added in v0.0.3
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
func (*StrAnyMap) UnmarshalValue ¶ added in v0.0.3
UnmarshalValue is an interface implement which sets any type of value for map.