Documentation
¶
Overview ¶
Package gmap provides concurrent-safe/unsafe maps.
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(other *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) SetIfNotExistFunc(key int, f func() bool) bool
- func (gm *IntBoolMap) SetIfNotExistFuncLock(key int, f func() 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(other *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) SetIfNotExistFunc(key int, f func() int) bool
- func (gm *IntIntMap) SetIfNotExistFuncLock(key int, f func() 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(other *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) SetIfNotExistFunc(key int, f func() interface{}) bool
- func (gm *IntInterfaceMap) SetIfNotExistFuncLock(key int, f func() 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(other *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) SetIfNotExistFunc(key int, f func() string) bool
- func (gm *IntStringMap) SetIfNotExistFuncLock(key int, f func() 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(unsafe ...bool) *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(other *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) SetIfNotExistFunc(key interface{}, f func() interface{}) bool
- func (gm *Map) SetIfNotExistFuncLock(key interface{}, f func() 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(other *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) SetIfNotExistFunc(key string, f func() bool) bool
- func (gm *StringBoolMap) SetIfNotExistFuncLock(key string, f func() 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(other *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) SetIfNotExistFunc(key string, f func() int) bool
- func (gm *StringIntMap) SetIfNotExistFuncLock(key string, f func() 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(other *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) SetIfNotExistFunc(key string, f func() interface{}) bool
- func (gm *StringInterfaceMap) SetIfNotExistFuncLock(key string, f func() 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(other *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) SetIfNotExistFunc(key string, f func() string) bool
- func (gm *StringStringMap) SetIfNotExistFuncLock(key string, f func() 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
NewIntBoolMap returns an empty IntBoolMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewIntBoolMapFrom ¶ added in v1.5.0
func NewIntBoolMapFrom(m map[int]bool, unsafe ...bool) *IntBoolMap
NewIntBoolMapFrom returns an IntBoolMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewIntBoolMapFromArray ¶ added in v1.5.0
func NewIntBoolMapFromArray(keys []int, values []bool, unsafe ...bool) *IntBoolMap
NewIntBoolMapFromArray returns an IntBoolMap from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*IntBoolMap) BatchRemove ¶ added in v1.5.0
func (gm *IntBoolMap) BatchRemove(keys []int)
BatchRemove batch deletes values of the map by keys.
func (*IntBoolMap) BatchSet ¶ added in v1.5.0
func (gm *IntBoolMap) BatchSet(m map[int]bool)
BatchSet batch sets key-values to the hash map.
func (*IntBoolMap) Clear ¶ added in v1.5.0
func (gm *IntBoolMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*IntBoolMap) Clone ¶ added in v1.5.0
func (gm *IntBoolMap) Clone() *IntBoolMap
Clone returns a new hash map with copy of current map data.
func (*IntBoolMap) Contains ¶ added in v1.5.0
func (gm *IntBoolMap) Contains(key int) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntBoolMap) Get ¶ added in v1.5.0
func (gm *IntBoolMap) Get(key int) bool
Get returns the value by given <key>.
func (*IntBoolMap) GetOrSet ¶ added in v1.5.0
func (gm *IntBoolMap) GetOrSet(key int, value bool) bool
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*IntBoolMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *IntBoolMap) GetOrSetFunc(key int, f func() bool) bool
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*IntBoolMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *IntBoolMap) GetOrSetFuncLock(key int, f func() bool) bool
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*IntBoolMap) IsEmpty ¶ added in v1.5.0
func (gm *IntBoolMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntBoolMap) Iterator ¶ added in v1.5.0
func (gm *IntBoolMap) Iterator(f func(k int, v bool) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*IntBoolMap) Keys ¶ added in v1.5.0
func (gm *IntBoolMap) Keys() []int
Keys returns all keys of the map as a slice.
func (*IntBoolMap) LockFunc ¶ added in v1.5.0
func (gm *IntBoolMap) LockFunc(f func(m map[int]bool))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*IntBoolMap) Map ¶ added in v1.5.0
func (gm *IntBoolMap) Map() map[int]bool
Map returns a copy of the data of the hash map.
func (*IntBoolMap) Merge ¶ added in v1.5.0
func (gm *IntBoolMap) Merge(other *IntBoolMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*IntBoolMap) RLockFunc ¶ added in v1.5.0
func (gm *IntBoolMap) RLockFunc(f func(m map[int]bool))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*IntBoolMap) Remove ¶ added in v1.5.0
func (gm *IntBoolMap) Remove(key int) bool
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntBoolMap) Set ¶ added in v1.5.0
func (gm *IntBoolMap) Set(key int, val bool)
Set sets key-value to the hash map.
func (*IntBoolMap) SetIfNotExist ¶ added in v1.5.0
func (gm *IntBoolMap) SetIfNotExist(key int, value bool) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntBoolMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *IntBoolMap) SetIfNotExistFunc(key int, f func() bool) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntBoolMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *IntBoolMap) SetIfNotExistFuncLock(key int, f func() bool) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*IntBoolMap) Size ¶ added in v1.5.0
func (gm *IntBoolMap) Size() int
Size returns the size of the map.
type IntIntMap ¶
type IntIntMap struct {
// contains filtered or unexported fields
}
func NewIntIntMap ¶
NewIntIntMap returns an empty IntIntMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewIntIntMapFrom ¶
NewIntIntMapFrom returns an IntIntMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewIntIntMapFromArray ¶ added in v1.5.0
NewIntIntMapFromArray returns an IntIntMap object from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*IntIntMap) BatchRemove ¶ added in v1.5.0
BatchRemove batch deletes values of the map by keys.
func (*IntIntMap) Clear ¶
func (gm *IntIntMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*IntIntMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntIntMap) Flip ¶
func (gm *IntIntMap) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*IntIntMap) GetOrSet ¶
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*IntIntMap) GetOrSetFunc ¶
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*IntIntMap) GetOrSetFuncLock ¶
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*IntIntMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntIntMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*IntIntMap) LockFunc ¶
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*IntIntMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*IntIntMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*IntIntMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntIntMap) SetIfNotExist ¶
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntIntMap) SetIfNotExistFunc ¶
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntIntMap) SetIfNotExistFuncLock ¶
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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.
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
NewIntInterfaceMap returns an empty IntInterfaceMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewIntInterfaceMapFrom ¶ added in v1.5.0
func NewIntInterfaceMapFrom(m map[int]interface{}, unsafe ...bool) *IntInterfaceMap
NewIntInterfaceMapFrom returns an IntInterfaceMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewIntInterfaceMapFromArray ¶ added in v1.5.0
func NewIntInterfaceMapFromArray(keys []int, values []interface{}, unsafe ...bool) *IntInterfaceMap
NewFromArray returns a hash map from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*IntInterfaceMap) BatchRemove ¶ added in v1.5.0
func (gm *IntInterfaceMap) BatchRemove(keys []int)
BatchRemove batch deletes values of the map by keys.
func (*IntInterfaceMap) BatchSet ¶ added in v1.5.0
func (gm *IntInterfaceMap) BatchSet(m map[int]interface{})
BatchSet batch sets key-values to the hash map.
func (*IntInterfaceMap) Clear ¶ added in v1.5.0
func (gm *IntInterfaceMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*IntInterfaceMap) Clone ¶ added in v1.5.0
func (gm *IntInterfaceMap) Clone() *IntInterfaceMap
Clone returns a new hash map with copy of current map data.
func (*IntInterfaceMap) Contains ¶ added in v1.5.0
func (gm *IntInterfaceMap) Contains(key int) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntInterfaceMap) Flip ¶ added in v1.5.0
func (gm *IntInterfaceMap) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*IntInterfaceMap) Get ¶ added in v1.5.0
func (gm *IntInterfaceMap) Get(key int) interface{}
Get returns the value by given <key>.
func (*IntInterfaceMap) GetOrSet ¶ added in v1.5.0
func (gm *IntInterfaceMap) GetOrSet(key int, value interface{}) interface{}
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*IntInterfaceMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *IntInterfaceMap) GetOrSetFunc(key int, f func() interface{}) interface{}
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*IntInterfaceMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *IntInterfaceMap) GetOrSetFuncLock(key int, f func() interface{}) interface{}
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*IntInterfaceMap) IsEmpty ¶ added in v1.5.0
func (gm *IntInterfaceMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntInterfaceMap) Iterator ¶ added in v1.5.0
func (gm *IntInterfaceMap) Iterator(f func(k int, v interface{}) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*IntInterfaceMap) Keys ¶ added in v1.5.0
func (gm *IntInterfaceMap) Keys() []int
Keys returns all keys of the map as a slice.
func (*IntInterfaceMap) LockFunc ¶ added in v1.5.0
func (gm *IntInterfaceMap) LockFunc(f func(m map[int]interface{}))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*IntInterfaceMap) Map ¶ added in v1.5.0
func (gm *IntInterfaceMap) Map() map[int]interface{}
Map returns a copy of the data of the hash map.
func (*IntInterfaceMap) Merge ¶ added in v1.5.0
func (gm *IntInterfaceMap) Merge(other *IntInterfaceMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*IntInterfaceMap) RLockFunc ¶ added in v1.5.0
func (gm *IntInterfaceMap) RLockFunc(f func(m map[int]interface{}))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*IntInterfaceMap) Remove ¶ added in v1.5.0
func (gm *IntInterfaceMap) Remove(key int) interface{}
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntInterfaceMap) Set ¶ added in v1.5.0
func (gm *IntInterfaceMap) Set(key int, val interface{})
Set sets key-value to the hash map.
func (*IntInterfaceMap) SetIfNotExist ¶ added in v1.5.0
func (gm *IntInterfaceMap) SetIfNotExist(key int, value interface{}) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntInterfaceMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *IntInterfaceMap) SetIfNotExistFunc(key int, f func() interface{}) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntInterfaceMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *IntInterfaceMap) SetIfNotExistFuncLock(key int, f func() interface{}) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*IntInterfaceMap) Size ¶ added in v1.5.0
func (gm *IntInterfaceMap) Size() int
Size returns the size of the map.
func (*IntInterfaceMap) Values ¶ added in v1.5.0
func (gm *IntInterfaceMap) Values() []interface{}
Values returns all values of the map as a slice.
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
NewIntStringMap returns an empty IntStringMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewIntStringMapFrom ¶ added in v1.5.0
func NewIntStringMapFrom(m map[int]string, unsafe ...bool) *IntStringMap
NewIntStringMapFrom returns an IntStringMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewIntStringMapFromArray ¶ added in v1.5.0
func NewIntStringMapFromArray(keys []int, values []string, unsafe ...bool) *IntStringMap
NewIntStringMapFromArray returns an IntStringMap object from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*IntStringMap) BatchRemove ¶ added in v1.5.0
func (gm *IntStringMap) BatchRemove(keys []int)
BatchRemove batch deletes values of the map by keys.
func (*IntStringMap) BatchSet ¶ added in v1.5.0
func (gm *IntStringMap) BatchSet(m map[int]string)
BatchSet batch sets key-values to the hash map.
func (*IntStringMap) Clear ¶ added in v1.5.0
func (gm *IntStringMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*IntStringMap) Clone ¶ added in v1.5.0
func (gm *IntStringMap) Clone() *IntStringMap
Clone returns a new hash map with copy of current map data.
func (*IntStringMap) Contains ¶ added in v1.5.0
func (gm *IntStringMap) Contains(key int) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntStringMap) Flip ¶ added in v1.5.0
func (gm *IntStringMap) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*IntStringMap) Get ¶ added in v1.5.0
func (gm *IntStringMap) Get(key int) string
Get returns the value by given <key>.
func (*IntStringMap) GetOrSet ¶ added in v1.5.0
func (gm *IntStringMap) GetOrSet(key int, value string) string
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*IntStringMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *IntStringMap) GetOrSetFunc(key int, f func() string) string
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*IntStringMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *IntStringMap) GetOrSetFuncLock(key int, f func() string) string
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*IntStringMap) IsEmpty ¶ added in v1.5.0
func (gm *IntStringMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntStringMap) Iterator ¶ added in v1.5.0
func (gm *IntStringMap) Iterator(f func(k int, v string) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*IntStringMap) Keys ¶ added in v1.5.0
func (gm *IntStringMap) Keys() []int
Keys returns all keys of the map as a slice.
func (*IntStringMap) LockFunc ¶ added in v1.5.0
func (gm *IntStringMap) LockFunc(f func(m map[int]string))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*IntStringMap) Map ¶ added in v1.5.0
func (gm *IntStringMap) Map() map[int]string
Map returns a copy of the data of the hash map.
func (*IntStringMap) Merge ¶ added in v1.5.0
func (gm *IntStringMap) Merge(other *IntStringMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*IntStringMap) RLockFunc ¶ added in v1.5.0
func (gm *IntStringMap) RLockFunc(f func(m map[int]string))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*IntStringMap) Remove ¶ added in v1.5.0
func (gm *IntStringMap) Remove(key int) string
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntStringMap) Set ¶ added in v1.5.0
func (gm *IntStringMap) Set(key int, val string)
Set sets key-value to the hash map.
func (*IntStringMap) SetIfNotExist ¶ added in v1.5.0
func (gm *IntStringMap) SetIfNotExist(key int, value string) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntStringMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *IntStringMap) SetIfNotExistFunc(key int, f func() string) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*IntStringMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *IntStringMap) SetIfNotExistFuncLock(key int, f func() string) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*IntStringMap) Size ¶ added in v1.5.0
func (gm *IntStringMap) Size() int
Size returns the size of the map.
func (*IntStringMap) Values ¶ added in v1.5.0
func (gm *IntStringMap) Values() []string
Values returns all values of the map as a slice.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func New ¶
New returns 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.
func NewFrom ¶
NewFrom returns a hash map from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewFromArray ¶ added in v1.5.0
NewFromArray returns a hash map from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*Map) BatchRemove ¶ added in v1.5.0
func (gm *Map) BatchRemove(keys []interface{})
BatchRemove batch deletes values of the map by keys.
func (*Map) BatchSet ¶ added in v1.5.0
func (gm *Map) BatchSet(m map[interface{}]interface{})
BatchSet batch sets key-values to the hash map.
func (*Map) Clear ¶ added in v1.5.0
func (gm *Map) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*Map) Contains ¶ added in v1.5.0
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*Map) Flip ¶ added in v1.5.0
func (gm *Map) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*Map) Get ¶ added in v1.5.0
func (gm *Map) Get(key interface{}) interface{}
Get returns the value by given <key>.
func (*Map) GetOrSet ¶ added in v1.5.0
func (gm *Map) GetOrSet(key interface{}, value interface{}) interface{}
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*Map) GetOrSetFunc ¶ added in v1.5.0
func (gm *Map) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*Map) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *Map) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*Map) IsEmpty ¶ added in v1.5.0
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*Map) Iterator ¶ added in v1.5.0
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*Map) Keys ¶ added in v1.5.0
func (gm *Map) Keys() []interface{}
Keys returns all keys of the map as a slice.
func (*Map) LockFunc ¶ added in v1.5.0
func (gm *Map) LockFunc(f func(m map[interface{}]interface{}))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*Map) Map ¶ added in v1.5.0
func (gm *Map) Map() map[interface{}]interface{}
Map returns a copy of the data of the hash map.
func (*Map) Merge ¶ added in v1.5.0
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*Map) RLockFunc ¶ added in v1.5.0
func (gm *Map) RLockFunc(f func(m map[interface{}]interface{}))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*Map) Remove ¶ added in v1.5.0
func (gm *Map) Remove(key interface{}) interface{}
Remove deletes value from map by given <key>, and return this deleted value.
func (*Map) Set ¶ added in v1.5.0
func (gm *Map) Set(key interface{}, val interface{})
Set sets key-value to the hash map.
func (*Map) SetIfNotExist ¶ added in v1.5.0
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*Map) SetIfNotExistFunc ¶ added in v1.6.0
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*Map) SetIfNotExistFuncLock ¶ added in v1.6.0
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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.
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
NewStringBoolMap returns an empty StringBoolMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewStringBoolMapFrom ¶ added in v1.5.0
func NewStringBoolMapFrom(m map[string]bool, unsafe ...bool) *StringBoolMap
NewStringBoolMapFrom returns an StringBoolMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewStringBoolMapFromArray ¶ added in v1.5.0
func NewStringBoolMapFromArray(keys []string, values []bool, unsafe ...bool) *StringBoolMap
NewFromArray returns a hash map from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*StringBoolMap) BatchRemove ¶ added in v1.5.0
func (gm *StringBoolMap) BatchRemove(keys []string)
BatchRemove batch deletes values of the map by keys.
func (*StringBoolMap) BatchSet ¶ added in v1.5.0
func (gm *StringBoolMap) BatchSet(m map[string]bool)
BatchSet batch sets key-values to the hash map.
func (*StringBoolMap) Clear ¶ added in v1.5.0
func (gm *StringBoolMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*StringBoolMap) Clone ¶ added in v1.5.0
func (gm *StringBoolMap) Clone() *StringBoolMap
Clone returns a new hash map with copy of current map data.
func (*StringBoolMap) Contains ¶ added in v1.5.0
func (gm *StringBoolMap) Contains(key string) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StringBoolMap) Get ¶ added in v1.5.0
func (gm *StringBoolMap) Get(key string) bool
Get returns the value by given <key>.
func (*StringBoolMap) GetOrSet ¶ added in v1.5.0
func (gm *StringBoolMap) GetOrSet(key string, value bool) bool
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StringBoolMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringBoolMap) GetOrSetFunc(key string, f func() bool) bool
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*StringBoolMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringBoolMap) GetOrSetFuncLock(key string, f func() bool) bool
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*StringBoolMap) IsEmpty ¶ added in v1.5.0
func (gm *StringBoolMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StringBoolMap) Iterator ¶ added in v1.5.0
func (gm *StringBoolMap) Iterator(f func(k string, v bool) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*StringBoolMap) Keys ¶ added in v1.5.0
func (gm *StringBoolMap) Keys() []string
Keys returns all keys of the map as a slice.
func (*StringBoolMap) LockFunc ¶ added in v1.5.0
func (gm *StringBoolMap) LockFunc(f func(m map[string]bool))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*StringBoolMap) Map ¶ added in v1.5.0
func (gm *StringBoolMap) Map() map[string]bool
Map returns a copy of the data of the hash map.
func (*StringBoolMap) Merge ¶ added in v1.5.0
func (gm *StringBoolMap) Merge(other *StringBoolMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*StringBoolMap) RLockFunc ¶ added in v1.5.0
func (gm *StringBoolMap) RLockFunc(f func(m map[string]bool))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*StringBoolMap) Remove ¶ added in v1.5.0
func (gm *StringBoolMap) Remove(key string) bool
Remove deletes value from map by given <key>, and return this deleted value.
func (*StringBoolMap) Set ¶ added in v1.5.0
func (gm *StringBoolMap) Set(key string, val bool)
Set sets key-value to the hash map.
func (*StringBoolMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringBoolMap) SetIfNotExist(key string, value bool) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringBoolMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *StringBoolMap) SetIfNotExistFunc(key string, f func() bool) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringBoolMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *StringBoolMap) SetIfNotExistFuncLock(key string, f func() bool) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*StringBoolMap) Size ¶ added in v1.5.0
func (gm *StringBoolMap) Size() int
Size returns the size of the map.
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
NewStringIntMap returns an empty StringIntMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewStringIntMapFrom ¶ added in v1.5.0
func NewStringIntMapFrom(m map[string]int, unsafe ...bool) *StringIntMap
NewStringIntMapFrom returns an StringIntMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewStringIntMapFromArray ¶ added in v1.5.0
func NewStringIntMapFromArray(keys []string, values []int, unsafe ...bool) *StringIntMap
NewStringIntMapFromArray returns an StringIntMap object from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*StringIntMap) BatchRemove ¶ added in v1.5.0
func (gm *StringIntMap) BatchRemove(keys []string)
BatchRemove batch deletes values of the map by keys.
func (*StringIntMap) BatchSet ¶ added in v1.5.0
func (gm *StringIntMap) BatchSet(m map[string]int)
BatchSet batch sets key-values to the hash map.
func (*StringIntMap) Clear ¶ added in v1.5.0
func (gm *StringIntMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*StringIntMap) Clone ¶ added in v1.5.0
func (gm *StringIntMap) Clone() *StringIntMap
Clone returns a new hash map with copy of current map data.
func (*StringIntMap) Contains ¶ added in v1.5.0
func (gm *StringIntMap) Contains(key string) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StringIntMap) Flip ¶ added in v1.5.0
func (gm *StringIntMap) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*StringIntMap) Get ¶ added in v1.5.0
func (gm *StringIntMap) Get(key string) int
Get returns the value by given <key>.
func (*StringIntMap) GetOrSet ¶ added in v1.5.0
func (gm *StringIntMap) GetOrSet(key string, value int) int
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StringIntMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringIntMap) GetOrSetFunc(key string, f func() int) int
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*StringIntMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringIntMap) GetOrSetFuncLock(key string, f func() int) int
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*StringIntMap) IsEmpty ¶ added in v1.5.0
func (gm *StringIntMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StringIntMap) Iterator ¶ added in v1.5.0
func (gm *StringIntMap) Iterator(f func(k string, v int) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*StringIntMap) Keys ¶ added in v1.5.0
func (gm *StringIntMap) Keys() []string
Keys returns all keys of the map as a slice.
func (*StringIntMap) LockFunc ¶ added in v1.5.0
func (gm *StringIntMap) LockFunc(f func(m map[string]int))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*StringIntMap) Map ¶ added in v1.5.0
func (gm *StringIntMap) Map() map[string]int
Map returns a copy of the data of the hash map.
func (*StringIntMap) Merge ¶ added in v1.5.0
func (gm *StringIntMap) Merge(other *StringIntMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*StringIntMap) RLockFunc ¶ added in v1.5.0
func (gm *StringIntMap) RLockFunc(f func(m map[string]int))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*StringIntMap) Remove ¶ added in v1.5.0
func (gm *StringIntMap) Remove(key string) int
Remove deletes value from map by given <key>, and return this deleted value.
func (*StringIntMap) Set ¶ added in v1.5.0
func (gm *StringIntMap) Set(key string, val int)
Set sets key-value to the hash map.
func (*StringIntMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringIntMap) SetIfNotExist(key string, value int) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringIntMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *StringIntMap) SetIfNotExistFunc(key string, f func() int) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringIntMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *StringIntMap) SetIfNotExistFuncLock(key string, f func() int) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*StringIntMap) Size ¶ added in v1.5.0
func (gm *StringIntMap) Size() int
Size returns the size of the map.
func (*StringIntMap) Values ¶ added in v1.5.0
func (gm *StringIntMap) Values() []int
Values returns all values of the map as a slice.
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
NewStringInterfaceMap returns an empty StringInterfaceMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewStringInterfaceMapFrom ¶ added in v1.5.0
func NewStringInterfaceMapFrom(m map[string]interface{}, unsafe ...bool) *StringInterfaceMap
NewStringInterfaceMapFrom returns an StringInterfaceMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewStringInterfaceMapFromArray ¶ added in v1.5.0
func NewStringInterfaceMapFromArray(keys []string, values []interface{}, unsafe ...bool) *StringInterfaceMap
NewStringInterfaceMapFromArray returns an StringInterfaceMap object from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*StringInterfaceMap) BatchRemove ¶ added in v1.5.0
func (gm *StringInterfaceMap) BatchRemove(keys []string)
BatchRemove batch deletes values of the map by keys.
func (*StringInterfaceMap) BatchSet ¶ added in v1.5.0
func (gm *StringInterfaceMap) BatchSet(m map[string]interface{})
BatchSet batch sets key-values to the hash map.
func (*StringInterfaceMap) Clear ¶ added in v1.5.0
func (gm *StringInterfaceMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*StringInterfaceMap) Clone ¶ added in v1.5.0
func (gm *StringInterfaceMap) Clone() *StringInterfaceMap
Clone returns a new hash map with copy of current map data.
func (*StringInterfaceMap) Contains ¶ added in v1.5.0
func (gm *StringInterfaceMap) Contains(key string) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StringInterfaceMap) Flip ¶ added in v1.5.0
func (gm *StringInterfaceMap) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*StringInterfaceMap) Get ¶ added in v1.5.0
func (gm *StringInterfaceMap) Get(key string) interface{}
Get returns the value by given <key>.
func (*StringInterfaceMap) GetOrSet ¶ added in v1.5.0
func (gm *StringInterfaceMap) GetOrSet(key string, value interface{}) interface{}
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StringInterfaceMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringInterfaceMap) GetOrSetFunc(key string, f func() interface{}) interface{}
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*StringInterfaceMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringInterfaceMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*StringInterfaceMap) IsEmpty ¶ added in v1.5.0
func (gm *StringInterfaceMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StringInterfaceMap) Iterator ¶ added in v1.5.0
func (gm *StringInterfaceMap) Iterator(f func(k string, v interface{}) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*StringInterfaceMap) Keys ¶ added in v1.5.0
func (gm *StringInterfaceMap) Keys() []string
Keys returns all keys of the map as a slice.
func (*StringInterfaceMap) LockFunc ¶ added in v1.5.0
func (gm *StringInterfaceMap) LockFunc(f func(m map[string]interface{}))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*StringInterfaceMap) Map ¶ added in v1.5.0
func (gm *StringInterfaceMap) Map() map[string]interface{}
Map returns a copy of the data of the hash map.
func (*StringInterfaceMap) Merge ¶ added in v1.5.0
func (gm *StringInterfaceMap) Merge(other *StringInterfaceMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*StringInterfaceMap) RLockFunc ¶ added in v1.5.0
func (gm *StringInterfaceMap) RLockFunc(f func(m map[string]interface{}))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*StringInterfaceMap) Remove ¶ added in v1.5.0
func (gm *StringInterfaceMap) Remove(key string) interface{}
Remove deletes value from map by given <key>, and return this deleted value.
func (*StringInterfaceMap) Set ¶ added in v1.5.0
func (gm *StringInterfaceMap) Set(key string, val interface{})
Set sets key-value to the hash map.
func (*StringInterfaceMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringInterfaceMap) SetIfNotExist(key string, value interface{}) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringInterfaceMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *StringInterfaceMap) SetIfNotExistFunc(key string, f func() interface{}) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringInterfaceMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *StringInterfaceMap) SetIfNotExistFuncLock(key string, f func() interface{}) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*StringInterfaceMap) Size ¶ added in v1.5.0
func (gm *StringInterfaceMap) Size() int
Size returns the size of the map.
func (*StringInterfaceMap) Values ¶ added in v1.5.0
func (gm *StringInterfaceMap) Values() []interface{}
Values returns all values of the map as a slice.
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
NewStringStringMap returns an empty StringStringMap object. The param <unsafe> used to specify whether using map with un-concurrent-safety, which is false in default, means concurrent-safe.
func NewStringStringMapFrom ¶ added in v1.5.0
func NewStringStringMapFrom(m map[string]string, unsafe ...bool) *StringStringMap
NewStringStringMapFrom returns an StringStringMap object from given map <m>. Notice that, the param map is a type of pointer, there might be some concurrent-safe issues when changing the map outside.
func NewStringStringMapFromArray ¶ added in v1.5.0
func NewStringStringMapFromArray(keys []string, values []string, unsafe ...bool) *StringStringMap
NewStringStringMapFromArray returns an StringStringMap object from given array. The param <keys> given as the keys of the map, and <values> as its corresponding values.
If length of <keys> is greater than that of <values>, the corresponding overflow map values will be the default value of its type.
func (*StringStringMap) BatchRemove ¶ added in v1.5.0
func (gm *StringStringMap) BatchRemove(keys []string)
BatchRemove batch deletes values of the map by keys.
func (*StringStringMap) BatchSet ¶ added in v1.5.0
func (gm *StringStringMap) BatchSet(m map[string]string)
BatchSet batch sets key-values to the hash map.
func (*StringStringMap) Clear ¶ added in v1.5.0
func (gm *StringStringMap) Clear()
Clear deletes all data of the map, it will remake a new underlying map data map.
func (*StringStringMap) Clone ¶ added in v1.5.0
func (gm *StringStringMap) Clone() *StringStringMap
Clone returns a new hash map with copy of current map data.
func (*StringStringMap) Contains ¶ added in v1.5.0
func (gm *StringStringMap) Contains(key string) bool
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StringStringMap) Flip ¶ added in v1.5.0
func (gm *StringStringMap) Flip()
Flip exchanges key-value of the map, it will change key-value to value-key.
func (*StringStringMap) Get ¶ added in v1.5.0
func (gm *StringStringMap) Get(key string) string
Get returns the value by given <key>.
func (*StringStringMap) GetOrSet ¶ added in v1.5.0
func (gm *StringStringMap) GetOrSet(key string, value string) string
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StringStringMap) GetOrSetFunc ¶ added in v1.5.0
func (gm *StringStringMap) GetOrSetFunc(key string, f func() string) string
GetOrSetFunc returns the value by key, or sets value with return value of callback function <f> if not exist and returns this value.
func (*StringStringMap) GetOrSetFuncLock ¶ added in v1.5.0
func (gm *StringStringMap) GetOrSetFuncLock(key string, f func() string) string
GetOrSetFuncLock returns the value by key, or sets value with return value of callback function <f> if 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 (*StringStringMap) IsEmpty ¶ added in v1.5.0
func (gm *StringStringMap) IsEmpty() bool
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StringStringMap) Iterator ¶ added in v1.5.0
func (gm *StringStringMap) Iterator(f func(k string, v string) bool)
Iterator iterates the hash map with custom callback function <f>. If f returns true, then continue iterating; or false to stop.
func (*StringStringMap) Keys ¶ added in v1.5.0
func (gm *StringStringMap) Keys() []string
Keys returns all keys of the map as a slice.
func (*StringStringMap) LockFunc ¶ added in v1.5.0
func (gm *StringStringMap) LockFunc(f func(m map[string]string))
LockFunc locks writing with given callback function <f> and mutex.Lock.
func (*StringStringMap) Map ¶ added in v1.5.0
func (gm *StringStringMap) Map() map[string]string
Map returns a copy of the data of the hash map.
func (*StringStringMap) Merge ¶ added in v1.5.0
func (gm *StringStringMap) Merge(other *StringStringMap)
Merge merges two hash maps. The <other> map will be merged into the map <gm>.
func (*StringStringMap) RLockFunc ¶ added in v1.5.0
func (gm *StringStringMap) RLockFunc(f func(m map[string]string))
RLockFunc locks reading with given callback function <f> and mutex.RLock.
func (*StringStringMap) Remove ¶ added in v1.5.0
func (gm *StringStringMap) Remove(key string) string
Remove deletes value from map by given <key>, and return this deleted value.
func (*StringStringMap) Set ¶ added in v1.5.0
func (gm *StringStringMap) Set(key string, val string)
Set sets key-value to the hash map.
func (*StringStringMap) SetIfNotExist ¶ added in v1.5.0
func (gm *StringStringMap) SetIfNotExist(key string, value string) bool
SetIfNotExist sets <value> to the map if the <key> does not exist, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringStringMap) SetIfNotExistFunc ¶ added in v1.6.0
func (gm *StringStringMap) SetIfNotExistFunc(key string, f func() string) bool
SetIfNotExistFunc sets value with return value of callback function <f>, then return true. It returns false if <key> exists, and <value> would be ignored.
func (*StringStringMap) SetIfNotExistFuncLock ¶ added in v1.6.0
func (gm *StringStringMap) SetIfNotExistFuncLock(key string, f func() string) bool
SetIfNotExistFuncLock sets value with return value of callback function <f>, then return 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 (*StringStringMap) Size ¶ added in v1.5.0
func (gm *StringStringMap) Size() int
Size returns the size of the map.
func (*StringStringMap) Values ¶ added in v1.5.0
func (gm *StringStringMap) Values() []string
Values returns all values of the map as a slice.