Documentation ¶
Overview ¶
Package gmap provides concurrent-safe/unsafe map containers.
Index ¶
- type AnyAnyMap
- func (m *AnyAnyMap) Clear()
- func (m *AnyAnyMap) Clone(safe ...bool) *AnyAnyMap
- func (m *AnyAnyMap) Contains(key interface{}) bool
- func (m *AnyAnyMap) Flip()
- func (m *AnyAnyMap) Get(key interface{}) interface{}
- func (m *AnyAnyMap) GetOrSet(key interface{}, value interface{}) interface{}
- func (m *AnyAnyMap) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
- func (m *AnyAnyMap) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
- func (m *AnyAnyMap) GetVar(key interface{}) *gvar.Var
- func (m *AnyAnyMap) GetVarOrSet(key interface{}, value interface{}) *gvar.Var
- func (m *AnyAnyMap) GetVarOrSetFunc(key interface{}, f func() interface{}) *gvar.Var
- func (m *AnyAnyMap) GetVarOrSetFuncLock(key interface{}, f func() interface{}) *gvar.Var
- func (m *AnyAnyMap) IsEmpty() bool
- func (m *AnyAnyMap) Iterator(f func(k interface{}, v interface{}) bool)
- func (m *AnyAnyMap) Keys() []interface{}
- func (m *AnyAnyMap) LockFunc(f func(m map[interface{}]interface{}))
- func (m *AnyAnyMap) Map() map[interface{}]interface{}
- func (m *AnyAnyMap) MarshalJSON() ([]byte, error)
- func (m *AnyAnyMap) Merge(other *AnyAnyMap)
- func (m *AnyAnyMap) RLockFunc(f func(m map[interface{}]interface{}))
- func (m *AnyAnyMap) Remove(key interface{}) interface{}
- func (m *AnyAnyMap) Removes(keys []interface{})
- func (m *AnyAnyMap) Search(key interface{}) (value interface{}, found bool)
- func (m *AnyAnyMap) Set(key interface{}, val interface{})
- func (m *AnyAnyMap) SetIfNotExist(key interface{}, value interface{}) bool
- func (m *AnyAnyMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool
- func (m *AnyAnyMap) SetIfNotExistFuncLock(key interface{}, f func() interface{}) bool
- func (m *AnyAnyMap) Sets(data map[interface{}]interface{})
- func (m *AnyAnyMap) Size() int
- func (m *AnyAnyMap) Values() []interface{}
- type HashMap
- type IntAnyMap
- func (m *IntAnyMap) Clear()
- func (m *IntAnyMap) Clone() *IntAnyMap
- func (m *IntAnyMap) Contains(key int) bool
- func (m *IntAnyMap) Flip()
- func (m *IntAnyMap) Get(key int) interface{}
- func (m *IntAnyMap) GetOrSet(key int, value interface{}) interface{}
- func (m *IntAnyMap) GetOrSetFunc(key int, f func() interface{}) interface{}
- func (m *IntAnyMap) GetOrSetFuncLock(key int, f func() interface{}) interface{}
- func (m *IntAnyMap) GetVar(key int) *gvar.Var
- func (m *IntAnyMap) GetVarOrSet(key int, value interface{}) *gvar.Var
- func (m *IntAnyMap) GetVarOrSetFunc(key int, f func() interface{}) *gvar.Var
- func (m *IntAnyMap) GetVarOrSetFuncLock(key int, f func() interface{}) *gvar.Var
- func (m *IntAnyMap) IsEmpty() bool
- func (m *IntAnyMap) Iterator(f func(k int, v interface{}) bool)
- func (m *IntAnyMap) Keys() []int
- func (m *IntAnyMap) LockFunc(f func(m map[int]interface{}))
- func (m *IntAnyMap) Map() map[int]interface{}
- func (m *IntAnyMap) MarshalJSON() ([]byte, error)
- func (m *IntAnyMap) Merge(other *IntAnyMap)
- func (m *IntAnyMap) RLockFunc(f func(m map[int]interface{}))
- func (m *IntAnyMap) Remove(key int) interface{}
- func (m *IntAnyMap) Removes(keys []int)
- func (m *IntAnyMap) Search(key int) (value interface{}, found bool)
- func (m *IntAnyMap) Set(key int, val interface{})
- func (m *IntAnyMap) SetIfNotExist(key int, value interface{}) bool
- func (m *IntAnyMap) SetIfNotExistFunc(key int, f func() interface{}) bool
- func (m *IntAnyMap) SetIfNotExistFuncLock(key int, f func() interface{}) bool
- func (m *IntAnyMap) Sets(data map[int]interface{})
- func (m *IntAnyMap) Size() int
- func (m *IntAnyMap) Values() []interface{}
- type IntIntMap
- func (m *IntIntMap) Clear()
- func (m *IntIntMap) Clone() *IntIntMap
- func (m *IntIntMap) Contains(key int) bool
- func (m *IntIntMap) Flip()
- func (m *IntIntMap) Get(key int) int
- func (m *IntIntMap) GetOrSet(key int, value int) int
- func (m *IntIntMap) GetOrSetFunc(key int, f func() int) int
- func (m *IntIntMap) GetOrSetFuncLock(key int, f func() int) int
- func (m *IntIntMap) IsEmpty() bool
- func (m *IntIntMap) Iterator(f func(k int, v int) bool)
- func (m *IntIntMap) Keys() []int
- func (m *IntIntMap) LockFunc(f func(m map[int]int))
- func (m *IntIntMap) Map() map[int]int
- func (m *IntIntMap) MarshalJSON() ([]byte, error)
- func (m *IntIntMap) Merge(other *IntIntMap)
- func (m *IntIntMap) RLockFunc(f func(m map[int]int))
- func (m *IntIntMap) Remove(key int) int
- func (m *IntIntMap) Removes(keys []int)
- func (m *IntIntMap) Search(key int) (value int, found bool)
- func (m *IntIntMap) Set(key int, val int)
- func (m *IntIntMap) SetIfNotExist(key int, value int) bool
- func (m *IntIntMap) SetIfNotExistFunc(key int, f func() int) bool
- func (m *IntIntMap) SetIfNotExistFuncLock(key int, f func() int) bool
- func (m *IntIntMap) Sets(data map[int]int)
- func (m *IntIntMap) Size() int
- func (m *IntIntMap) Values() []int
- type IntStrMap
- func (m *IntStrMap) Clear()
- func (m *IntStrMap) Clone() *IntStrMap
- func (m *IntStrMap) Contains(key int) bool
- func (m *IntStrMap) Flip()
- func (m *IntStrMap) Get(key int) string
- func (m *IntStrMap) GetOrSet(key int, value string) string
- func (m *IntStrMap) GetOrSetFunc(key int, f func() string) string
- func (m *IntStrMap) GetOrSetFuncLock(key int, f func() string) string
- func (m *IntStrMap) IsEmpty() bool
- func (m *IntStrMap) Iterator(f func(k int, v string) bool)
- func (m *IntStrMap) Keys() []int
- func (m *IntStrMap) LockFunc(f func(m map[int]string))
- func (m *IntStrMap) Map() map[int]string
- func (m *IntStrMap) MarshalJSON() ([]byte, error)
- func (m *IntStrMap) Merge(other *IntStrMap)
- func (m *IntStrMap) RLockFunc(f func(m map[int]string))
- func (m *IntStrMap) Remove(key int) string
- func (m *IntStrMap) Removes(keys []int)
- func (m *IntStrMap) Search(key int) (value string, found bool)
- func (m *IntStrMap) Set(key int, val string)
- func (m *IntStrMap) SetIfNotExist(key int, value string) bool
- func (m *IntStrMap) SetIfNotExistFunc(key int, f func() string) bool
- func (m *IntStrMap) SetIfNotExistFuncLock(key int, f func() string) bool
- func (m *IntStrMap) Sets(data map[int]string)
- func (m *IntStrMap) Size() int
- func (m *IntStrMap) Values() []string
- type ListMap
- func (m *ListMap) Clear()
- func (m *ListMap) Clone(safe ...bool) *ListMap
- func (m *ListMap) Contains(key interface{}) (ok bool)
- func (m *ListMap) Flip()
- func (m *ListMap) Get(key interface{}) (value interface{})
- func (m *ListMap) GetOrSet(key interface{}, value interface{}) interface{}
- func (m *ListMap) GetOrSetFunc(key interface{}, f func() interface{}) interface{}
- func (m *ListMap) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}
- func (m *ListMap) GetVar(key interface{}) *gvar.Var
- func (m *ListMap) GetVarOrSet(key interface{}, value interface{}) *gvar.Var
- func (m *ListMap) GetVarOrSetFunc(key interface{}, f func() interface{}) *gvar.Var
- func (m *ListMap) GetVarOrSetFuncLock(key interface{}, f func() interface{}) *gvar.Var
- func (m *ListMap) IsEmpty() bool
- func (m *ListMap) Iterator(f func(key, value interface{}) bool)
- func (m *ListMap) IteratorAsc(f func(key interface{}, value interface{}) bool)
- func (m *ListMap) IteratorDesc(f func(key interface{}, value interface{}) bool)
- func (m *ListMap) Keys() []interface{}
- func (m *ListMap) Map() map[interface{}]interface{}
- func (m *ListMap) MarshalJSON() ([]byte, error)
- func (m *ListMap) Merge(other *ListMap)
- func (m *ListMap) Remove(key interface{}) (value interface{})
- func (m *ListMap) Removes(keys []interface{})
- func (m *ListMap) Search(key interface{}) (value interface{}, found bool)
- func (m *ListMap) Set(key interface{}, value interface{})
- func (m *ListMap) SetIfNotExist(key interface{}, value interface{}) bool
- func (m *ListMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool
- func (m *ListMap) SetIfNotExistFuncLock(key interface{}, f func() interface{}) bool
- func (m *ListMap) Sets(data map[interface{}]interface{})
- func (m *ListMap) Size() (size int)
- func (m *ListMap) Values() []interface{}
- type Map
- type StrAnyMap
- func (m *StrAnyMap) Clear()
- func (m *StrAnyMap) Clone() *StrAnyMap
- func (m *StrAnyMap) Contains(key string) bool
- func (m *StrAnyMap) Flip()
- func (m *StrAnyMap) Get(key string) interface{}
- func (m *StrAnyMap) GetOrSet(key string, value interface{}) interface{}
- func (m *StrAnyMap) GetOrSetFunc(key string, f func() interface{}) interface{}
- func (m *StrAnyMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}
- func (m *StrAnyMap) GetVar(key string) *gvar.Var
- func (m *StrAnyMap) GetVarOrSet(key string, value interface{}) *gvar.Var
- func (m *StrAnyMap) GetVarOrSetFunc(key string, f func() interface{}) *gvar.Var
- func (m *StrAnyMap) GetVarOrSetFuncLock(key string, f func() interface{}) *gvar.Var
- func (m *StrAnyMap) IsEmpty() bool
- func (m *StrAnyMap) Iterator(f func(k string, v interface{}) bool)
- func (m *StrAnyMap) Keys() []string
- func (m *StrAnyMap) LockFunc(f func(m map[string]interface{}))
- func (m *StrAnyMap) Map() map[string]interface{}
- func (m *StrAnyMap) MarshalJSON() ([]byte, error)
- func (m *StrAnyMap) Merge(other *StrAnyMap)
- func (m *StrAnyMap) RLockFunc(f func(m map[string]interface{}))
- func (m *StrAnyMap) Remove(key string) interface{}
- func (m *StrAnyMap) Removes(keys []string)
- func (m *StrAnyMap) Search(key string) (value interface{}, found bool)
- func (m *StrAnyMap) Set(key string, val interface{})
- func (m *StrAnyMap) SetIfNotExist(key string, value interface{}) bool
- func (m *StrAnyMap) SetIfNotExistFunc(key string, f func() interface{}) bool
- func (m *StrAnyMap) SetIfNotExistFuncLock(key string, f func() interface{}) bool
- func (m *StrAnyMap) Sets(data map[string]interface{})
- func (m *StrAnyMap) Size() int
- func (m *StrAnyMap) Values() []interface{}
- type StrIntMap
- func (m *StrIntMap) Clear()
- func (m *StrIntMap) Clone() *StrIntMap
- func (m *StrIntMap) Contains(key string) bool
- func (m *StrIntMap) Flip()
- func (m *StrIntMap) Get(key string) int
- func (m *StrIntMap) GetOrSet(key string, value int) int
- func (m *StrIntMap) GetOrSetFunc(key string, f func() int) int
- func (m *StrIntMap) GetOrSetFuncLock(key string, f func() int) int
- func (m *StrIntMap) IsEmpty() bool
- func (m *StrIntMap) Iterator(f func(k string, v int) bool)
- func (m *StrIntMap) Keys() []string
- func (m *StrIntMap) LockFunc(f func(m map[string]int))
- func (m *StrIntMap) Map() map[string]int
- func (m *StrIntMap) MarshalJSON() ([]byte, error)
- func (m *StrIntMap) Merge(other *StrIntMap)
- func (m *StrIntMap) RLockFunc(f func(m map[string]int))
- func (m *StrIntMap) Remove(key string) int
- func (m *StrIntMap) Removes(keys []string)
- func (m *StrIntMap) Search(key string) (value int, found bool)
- func (m *StrIntMap) Set(key string, val int)
- func (m *StrIntMap) SetIfNotExist(key string, value int) bool
- func (m *StrIntMap) SetIfNotExistFunc(key string, f func() int) bool
- func (m *StrIntMap) SetIfNotExistFuncLock(key string, f func() int) bool
- func (m *StrIntMap) Sets(data map[string]int)
- func (m *StrIntMap) Size() int
- func (m *StrIntMap) Values() []int
- type StrStrMap
- func (m *StrStrMap) Clear()
- func (m *StrStrMap) Clone() *StrStrMap
- func (m *StrStrMap) Contains(key string) bool
- func (m *StrStrMap) Flip()
- func (m *StrStrMap) Get(key string) string
- func (m *StrStrMap) GetOrSet(key string, value string) string
- func (m *StrStrMap) GetOrSetFunc(key string, f func() string) string
- func (m *StrStrMap) GetOrSetFuncLock(key string, f func() string) string
- func (m *StrStrMap) IsEmpty() bool
- func (m *StrStrMap) Iterator(f func(k string, v string) bool)
- func (m *StrStrMap) Keys() []string
- func (m *StrStrMap) LockFunc(f func(m map[string]string))
- func (m *StrStrMap) Map() map[string]string
- func (m *StrStrMap) MarshalJSON() ([]byte, error)
- func (m *StrStrMap) Merge(other *StrStrMap)
- func (m *StrStrMap) RLockFunc(f func(m map[string]string))
- func (m *StrStrMap) Remove(key string) string
- func (m *StrStrMap) Removes(keys []string)
- func (m *StrStrMap) Search(key string) (value string, found bool)
- func (m *StrStrMap) Set(key string, val string)
- func (m *StrStrMap) SetIfNotExist(key string, value string) bool
- func (m *StrStrMap) SetIfNotExistFunc(key string, f func() string) bool
- func (m *StrStrMap) SetIfNotExistFuncLock(key string, f func() string) bool
- func (m *StrStrMap) Sets(data map[string]string)
- func (m *StrStrMap) Size() int
- func (m *StrStrMap) Values() []string
- type TreeMap
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
}
func NewAnyAnyMap ¶
NewAnyAnyMap returns an empty hash map. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewAnyAnyMapFrom ¶
NewAnyAnyMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*AnyAnyMap) Clear ¶
func (m *AnyAnyMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*AnyAnyMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*AnyAnyMap) Flip ¶
func (m *AnyAnyMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*AnyAnyMap) Get ¶
func (m *AnyAnyMap) Get(key interface{}) interface{}
Get returns the value by given <key>.
func (*AnyAnyMap) GetOrSet ¶
func (m *AnyAnyMap) 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 (*AnyAnyMap) GetOrSetFunc ¶
func (m *AnyAnyMap) 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 (*AnyAnyMap) GetOrSetFuncLock ¶
func (m *AnyAnyMap) 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 (*AnyAnyMap) GetVar ¶
GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.
func (*AnyAnyMap) GetVarOrSet ¶
GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.
func (*AnyAnyMap) GetVarOrSetFunc ¶
GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.
func (*AnyAnyMap) GetVarOrSetFuncLock ¶
GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.
func (*AnyAnyMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*AnyAnyMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*AnyAnyMap) Keys ¶
func (m *AnyAnyMap) Keys() []interface{}
Keys returns all keys of the map as a slice.
func (*AnyAnyMap) LockFunc ¶
func (m *AnyAnyMap) LockFunc(f func(m map[interface{}]interface{}))
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*AnyAnyMap) Map ¶
func (m *AnyAnyMap) Map() map[interface{}]interface{}
Map returns a copy of the data of the hash map.
func (*AnyAnyMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*AnyAnyMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*AnyAnyMap) RLockFunc ¶
func (m *AnyAnyMap) RLockFunc(f func(m map[interface{}]interface{}))
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*AnyAnyMap) Remove ¶
func (m *AnyAnyMap) Remove(key interface{}) interface{}
Remove deletes value from map by given <key>, and return this deleted value.
func (*AnyAnyMap) Removes ¶
func (m *AnyAnyMap) Removes(keys []interface{})
Removes batch deletes values of the map by keys.
func (*AnyAnyMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*AnyAnyMap) Set ¶
func (m *AnyAnyMap) Set(key interface{}, val interface{})
Set sets key-value to the hash map.
func (*AnyAnyMap) 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 (*AnyAnyMap) 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 (*AnyAnyMap) 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 IntAnyMap ¶
type IntAnyMap struct {
// contains filtered or unexported fields
}
func NewIntAnyMap ¶
NewIntAnyMap returns an empty IntAnyMap object. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewIntAnyMapFrom ¶
NewIntAnyMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*IntAnyMap) Clear ¶
func (m *IntAnyMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*IntAnyMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntAnyMap) Flip ¶
func (m *IntAnyMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*IntAnyMap) GetOrSet ¶
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*IntAnyMap) 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 (*IntAnyMap) 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 (*IntAnyMap) GetVar ¶
GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.
func (*IntAnyMap) GetVarOrSet ¶
GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.
func (*IntAnyMap) GetVarOrSetFunc ¶
GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.
func (*IntAnyMap) GetVarOrSetFuncLock ¶
GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.
func (*IntAnyMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntAnyMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*IntAnyMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*IntAnyMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*IntAnyMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*IntAnyMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*IntAnyMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntAnyMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*IntAnyMap) 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 (*IntAnyMap) 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 (*IntAnyMap) 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 IntIntMap ¶
type IntIntMap struct {
// contains filtered or unexported fields
}
func NewIntIntMap ¶
NewIntIntMap returns an empty IntIntMap object. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewIntIntMapFrom ¶
NewIntIntMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*IntIntMap) Clear ¶
func (m *IntIntMap) Clear()
Clear deletes all data of the map, it will remake a new underlying 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 (m *IntIntMap) Flip()
Flip exchanges key-value of the map 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 it continues iterating; or false to stop.
func (*IntIntMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*IntIntMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*IntIntMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*IntIntMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*IntIntMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntIntMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
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 IntStrMap ¶
type IntStrMap struct {
// contains filtered or unexported fields
}
func NewIntStrMap ¶
NewIntStrMap returns an empty IntStrMap object. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewIntStrMapFrom ¶
NewIntStrMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*IntStrMap) Clear ¶
func (m *IntStrMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*IntStrMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*IntStrMap) Flip ¶
func (m *IntStrMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*IntStrMap) GetOrSet ¶
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*IntStrMap) 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 (*IntStrMap) 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 (*IntStrMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*IntStrMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*IntStrMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*IntStrMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*IntStrMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*IntStrMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*IntStrMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*IntStrMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*IntStrMap) 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 (*IntStrMap) 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 (*IntStrMap) 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 ListMap ¶
type ListMap struct {
// contains filtered or unexported fields
}
func NewListMap ¶
NewListMap returns an empty link map. ListMap is backed by a hash table to store values and doubly-linked list to store ordering. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewListMapFrom ¶
NewListMapFrom returns a link map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*ListMap) Clear ¶
func (m *ListMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*ListMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*ListMap) Get ¶
func (m *ListMap) Get(key interface{}) (value interface{})
Get returns the value by given <key>.
func (*ListMap) GetOrSet ¶
func (m *ListMap) 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 (*ListMap) GetOrSetFunc ¶
func (m *ListMap) 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 (*ListMap) GetOrSetFuncLock ¶
func (m *ListMap) 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 map.
func (*ListMap) GetVar ¶
GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.
func (*ListMap) GetVarOrSet ¶
GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.
func (*ListMap) GetVarOrSetFunc ¶
GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.
func (*ListMap) GetVarOrSetFuncLock ¶
GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.
func (*ListMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*ListMap) IteratorAsc ¶
IteratorAsc iterates the map in ascending order with given callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*ListMap) IteratorDesc ¶
IteratorDesc iterates the map in descending order with given callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*ListMap) Keys ¶
func (m *ListMap) Keys() []interface{}
Keys returns all keys of the map as a slice in ascending order.
func (*ListMap) Map ¶
func (m *ListMap) Map() map[interface{}]interface{}
Map returns a copy of the data of the map.
func (*ListMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ListMap) Merge ¶
Merge merges two link maps. The <other> map will be merged into the map <m>.
func (*ListMap) Remove ¶
func (m *ListMap) Remove(key interface{}) (value interface{})
Remove deletes value from map by given <key>, and return this deleted value.
func (*ListMap) Removes ¶
func (m *ListMap) Removes(keys []interface{})
Removes batch deletes values of the map by keys.
func (*ListMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*ListMap) Set ¶
func (m *ListMap) Set(key interface{}, value interface{})
Set sets key-value to the map.
func (*ListMap) 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 (*ListMap) 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 (*ListMap) 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 map.
type Map ¶
type Map = AnyAnyMap
Map based on hash table, alias of AnyAnyMap.
func New ¶
New returns an empty hash map. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewFrom ¶
NewFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside. The parameter <unsafe> used to specify whether using tree in un-concurrent-safety, which is false in default.
func NewHashMap ¶
NewHashMap returns an empty hash map. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewHashMapFrom ¶
NewHashMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside. The parameter <unsafe> used to specify whether using tree in un-concurrent-safety, which is false in default.
type StrAnyMap ¶
type StrAnyMap struct {
// contains filtered or unexported fields
}
func NewStrAnyMap ¶
NewStrAnyMap returns an empty StrAnyMap object. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewStrAnyMapFrom ¶
NewStrAnyMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*StrAnyMap) Clear ¶
func (m *StrAnyMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*StrAnyMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StrAnyMap) Flip ¶
func (m *StrAnyMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*StrAnyMap) GetOrSet ¶
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StrAnyMap) 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 (*StrAnyMap) 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 (*StrAnyMap) GetVar ¶
GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.
func (*StrAnyMap) GetVarOrSet ¶
GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.
func (*StrAnyMap) GetVarOrSetFunc ¶
GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.
func (*StrAnyMap) GetVarOrSetFuncLock ¶
GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.
func (*StrAnyMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StrAnyMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*StrAnyMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*StrAnyMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*StrAnyMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*StrAnyMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*StrAnyMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*StrAnyMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*StrAnyMap) 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 (*StrAnyMap) 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 (*StrAnyMap) 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 StrIntMap ¶
type StrIntMap struct {
// contains filtered or unexported fields
}
func NewStrIntMap ¶
NewStrIntMap returns an empty StrIntMap object. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewStrIntMapFrom ¶
NewStrIntMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*StrIntMap) Clear ¶
func (m *StrIntMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*StrIntMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StrIntMap) Flip ¶
func (m *StrIntMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*StrIntMap) GetOrSet ¶
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StrIntMap) 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 (*StrIntMap) 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 (*StrIntMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StrIntMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*StrIntMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*StrIntMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*StrIntMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*StrIntMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*StrIntMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*StrIntMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*StrIntMap) 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 (*StrIntMap) 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 (*StrIntMap) 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 StrStrMap ¶
type StrStrMap struct {
// contains filtered or unexported fields
}
func NewStrStrMap ¶
NewStrStrMap returns an empty StrStrMap object. The parameter <safe> used to specify whether using map in concurrent-safety, which is false in default.
func NewStrStrMapFrom ¶
NewStrStrMapFrom returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*StrStrMap) Clear ¶
func (m *StrStrMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*StrStrMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StrStrMap) Flip ¶
func (m *StrStrMap) Flip()
Flip exchanges key-value of the map to value-key.
func (*StrStrMap) GetOrSet ¶
GetOrSet returns the value by key, or set value with given <value> if not exist and returns this value.
func (*StrStrMap) 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 (*StrStrMap) 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 (*StrStrMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StrStrMap) Iterator ¶
Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*StrStrMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*StrStrMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*StrStrMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*StrStrMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*StrStrMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*StrStrMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*StrStrMap) 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 (*StrStrMap) 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 (*StrStrMap) 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 TreeMap ¶
type TreeMap = gtree.RedBlackTree
Map based on red-black tree, alias of RedBlackTree.
func NewTreeMap ¶
NewTreeMap instantiates a tree map with the custom comparator. The parameter <unsafe> used to specify whether using tree in un-concurrent-safety, which is false in default.
func NewTreeMapFrom ¶
func NewTreeMapFrom(comparator func(v1, v2 interface{}) int, data map[interface{}]interface{}, safe ...bool) *TreeMap
NewTreeMapFrom instantiates a tree map with the custom comparator and <data> map. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside. The parameter <unsafe> used to specify whether using tree in un-concurrent-safety, which is false in default.