gf: github.com/gogf/gf/container/gmap Index | Files

package gmap

import "github.com/gogf/gf/container/gmap"

Package gmap provides concurrent-safe/unsafe map containers.

Index

Package Files

gmap.go gmap_hash_any_any_map.go gmap_hash_int_any_map.go gmap_hash_int_int_map.go gmap_hash_int_str_map.go gmap_hash_str_any_map.go gmap_hash_str_int_map.go gmap_hash_str_str_map.go gmap_list_map.go gmap_tree_map.go

type AnyAnyMap Uses

type AnyAnyMap struct {
    // contains filtered or unexported fields
}

func NewAnyAnyMap Uses

func NewAnyAnyMap(safe ...bool) *AnyAnyMap

NewAnyAnyMap creates and returns an empty hash map. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewAnyAnyMapFrom Uses

func NewAnyAnyMapFrom(data map[interface{}]interface{}, safe ...bool) *AnyAnyMap

NewAnyAnyMapFrom creates and 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 Uses

func (m *AnyAnyMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*AnyAnyMap) Clone Uses

func (m *AnyAnyMap) Clone(safe ...bool) *AnyAnyMap

Clone returns a new hash map with copy of current map data.

func (*AnyAnyMap) Contains Uses

func (m *AnyAnyMap) Contains(key interface{}) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*AnyAnyMap) FilterEmpty Uses

func (m *AnyAnyMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*AnyAnyMap) Flip Uses

func (m *AnyAnyMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*AnyAnyMap) Get Uses

func (m *AnyAnyMap) Get(key interface{}) interface{}

Get returns the value by given <key>.

func (*AnyAnyMap) GetOrSet Uses

func (m *AnyAnyMap) GetOrSet(key interface{}, value interface{}) interface{}

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*AnyAnyMap) GetOrSetFunc Uses

func (m *AnyAnyMap) GetOrSetFunc(key interface{}, f func() interface{}) interface{}

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

func (*AnyAnyMap) GetOrSetFuncLock Uses

func (m *AnyAnyMap) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*AnyAnyMap) GetVar Uses

func (m *AnyAnyMap) GetVar(key interface{}) *gvar.Var

GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.

func (*AnyAnyMap) GetVarOrSet Uses

func (m *AnyAnyMap) GetVarOrSet(key interface{}, value interface{}) *gvar.Var

GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.

func (*AnyAnyMap) GetVarOrSetFunc Uses

func (m *AnyAnyMap) GetVarOrSetFunc(key interface{}, f func() interface{}) *gvar.Var

GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.

func (*AnyAnyMap) GetVarOrSetFuncLock Uses

func (m *AnyAnyMap) GetVarOrSetFuncLock(key interface{}, f func() interface{}) *gvar.Var

GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.

func (*AnyAnyMap) IsEmpty Uses

func (m *AnyAnyMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*AnyAnyMap) Iterator Uses

func (m *AnyAnyMap) Iterator(f func(k interface{}, v interface{}) bool)

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 Uses

func (m *AnyAnyMap) Keys() []interface{}

Keys returns all keys of the map as a slice.

func (*AnyAnyMap) LockFunc Uses

func (m *AnyAnyMap) LockFunc(f func(m map[interface{}]interface{}))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*AnyAnyMap) Map Uses

func (m *AnyAnyMap) Map() map[interface{}]interface{}

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*AnyAnyMap) MapCopy Uses

func (m *AnyAnyMap) MapCopy() map[interface{}]interface{}

MapCopy returns a copy of the underlying data of the hash map.

func (*AnyAnyMap) MapStrAny Uses

func (m *AnyAnyMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*AnyAnyMap) MarshalJSON Uses

func (m *AnyAnyMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*AnyAnyMap) Merge Uses

func (m *AnyAnyMap) Merge(other *AnyAnyMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*AnyAnyMap) Pop Uses

func (m *AnyAnyMap) Pop() (key, value interface{})

Pop retrieves and deletes an item from the map.

func (*AnyAnyMap) Pops Uses

func (m *AnyAnyMap) Pops(size int) map[interface{}]interface{}

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*AnyAnyMap) RLockFunc Uses

func (m *AnyAnyMap) RLockFunc(f func(m map[interface{}]interface{}))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*AnyAnyMap) Remove Uses

func (m *AnyAnyMap) Remove(key interface{}) interface{}

Remove deletes value from map by given <key>, and return this deleted value.

func (*AnyAnyMap) Removes Uses

func (m *AnyAnyMap) Removes(keys []interface{})

Removes batch deletes values of the map by keys.

func (*AnyAnyMap) Replace Uses

func (m *AnyAnyMap) Replace(data map[interface{}]interface{})

Replace the data of the map with given <data>.

func (*AnyAnyMap) Search Uses

func (m *AnyAnyMap) Search(key interface{}) (value interface{}, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*AnyAnyMap) Set Uses

func (m *AnyAnyMap) Set(key interface{}, val interface{})

Set sets key-value to the hash map.

func (*AnyAnyMap) SetIfNotExist Uses

func (m *AnyAnyMap) SetIfNotExist(key interface{}, value interface{}) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*AnyAnyMap) SetIfNotExistFunc Uses

func (m *AnyAnyMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*AnyAnyMap) SetIfNotExistFuncLock Uses

func (m *AnyAnyMap) SetIfNotExistFuncLock(key interface{}, f func() interface{}) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*AnyAnyMap) Sets Uses

func (m *AnyAnyMap) Sets(data map[interface{}]interface{})

Sets batch sets key-values to the hash map.

func (*AnyAnyMap) Size Uses

func (m *AnyAnyMap) Size() int

Size returns the size of the map.

func (*AnyAnyMap) UnmarshalJSON Uses

func (m *AnyAnyMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*AnyAnyMap) Values Uses

func (m *AnyAnyMap) Values() []interface{}

Values returns all values of the map as a slice.

type HashMap Uses

type HashMap = AnyAnyMap

type IntAnyMap Uses

type IntAnyMap struct {
    // contains filtered or unexported fields
}

func NewIntAnyMap Uses

func NewIntAnyMap(safe ...bool) *IntAnyMap

NewIntAnyMap returns an empty IntAnyMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewIntAnyMapFrom Uses

func NewIntAnyMapFrom(data map[int]interface{}, safe ...bool) *IntAnyMap

NewIntAnyMapFrom creates and 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 Uses

func (m *IntAnyMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*IntAnyMap) Clone Uses

func (m *IntAnyMap) Clone() *IntAnyMap

Clone returns a new hash map with copy of current map data.

func (*IntAnyMap) Contains Uses

func (m *IntAnyMap) Contains(key int) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*IntAnyMap) FilterEmpty Uses

func (m *IntAnyMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*IntAnyMap) Flip Uses

func (m *IntAnyMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*IntAnyMap) Get Uses

func (m *IntAnyMap) Get(key int) interface{}

Get returns the value by given <key>.

func (*IntAnyMap) GetOrSet Uses

func (m *IntAnyMap) GetOrSet(key int, value interface{}) interface{}

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*IntAnyMap) GetOrSetFunc Uses

func (m *IntAnyMap) GetOrSetFunc(key int, f func() interface{}) interface{}

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.

func (*IntAnyMap) GetOrSetFuncLock Uses

func (m *IntAnyMap) GetOrSetFuncLock(key int, f func() interface{}) interface{}

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*IntAnyMap) GetVar Uses

func (m *IntAnyMap) GetVar(key int) *gvar.Var

GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.

func (*IntAnyMap) GetVarOrSet Uses

func (m *IntAnyMap) GetVarOrSet(key int, value interface{}) *gvar.Var

GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.

func (*IntAnyMap) GetVarOrSetFunc Uses

func (m *IntAnyMap) GetVarOrSetFunc(key int, f func() interface{}) *gvar.Var

GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.

func (*IntAnyMap) GetVarOrSetFuncLock Uses

func (m *IntAnyMap) GetVarOrSetFuncLock(key int, f func() interface{}) *gvar.Var

GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.

func (*IntAnyMap) IsEmpty Uses

func (m *IntAnyMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*IntAnyMap) Iterator Uses

func (m *IntAnyMap) Iterator(f func(k int, v interface{}) bool)

Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*IntAnyMap) Keys Uses

func (m *IntAnyMap) Keys() []int

Keys returns all keys of the map as a slice.

func (*IntAnyMap) LockFunc Uses

func (m *IntAnyMap) LockFunc(f func(m map[int]interface{}))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*IntAnyMap) Map Uses

func (m *IntAnyMap) Map() map[int]interface{}

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*IntAnyMap) MapCopy Uses

func (m *IntAnyMap) MapCopy() map[int]interface{}

MapCopy returns a copy of the underlying data of the hash map.

func (*IntAnyMap) MapStrAny Uses

func (m *IntAnyMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*IntAnyMap) MarshalJSON Uses

func (m *IntAnyMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*IntAnyMap) Merge Uses

func (m *IntAnyMap) Merge(other *IntAnyMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*IntAnyMap) Pop Uses

func (m *IntAnyMap) Pop() (key int, value interface{})

Pop retrieves and deletes an item from the map.

func (*IntAnyMap) Pops Uses

func (m *IntAnyMap) Pops(size int) map[int]interface{}

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*IntAnyMap) RLockFunc Uses

func (m *IntAnyMap) RLockFunc(f func(m map[int]interface{}))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*IntAnyMap) Remove Uses

func (m *IntAnyMap) Remove(key int) interface{}

Remove deletes value from map by given <key>, and return this deleted value.

func (*IntAnyMap) Removes Uses

func (m *IntAnyMap) Removes(keys []int)

Removes batch deletes values of the map by keys.

func (*IntAnyMap) Replace Uses

func (m *IntAnyMap) Replace(data map[int]interface{})

Replace the data of the map with given <data>.

func (*IntAnyMap) Search Uses

func (m *IntAnyMap) Search(key int) (value interface{}, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*IntAnyMap) Set Uses

func (m *IntAnyMap) Set(key int, val interface{})

Set sets key-value to the hash map.

func (*IntAnyMap) SetIfNotExist Uses

func (m *IntAnyMap) SetIfNotExist(key int, value interface{}) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*IntAnyMap) SetIfNotExistFunc Uses

func (m *IntAnyMap) SetIfNotExistFunc(key int, f func() interface{}) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*IntAnyMap) SetIfNotExistFuncLock Uses

func (m *IntAnyMap) SetIfNotExistFuncLock(key int, f func() interface{}) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*IntAnyMap) Sets Uses

func (m *IntAnyMap) Sets(data map[int]interface{})

Sets batch sets key-values to the hash map.

func (*IntAnyMap) Size Uses

func (m *IntAnyMap) Size() int

Size returns the size of the map.

func (*IntAnyMap) UnmarshalJSON Uses

func (m *IntAnyMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*IntAnyMap) Values Uses

func (m *IntAnyMap) Values() []interface{}

Values returns all values of the map as a slice.

type IntIntMap Uses

type IntIntMap struct {
    // contains filtered or unexported fields
}

func NewIntIntMap Uses

func NewIntIntMap(safe ...bool) *IntIntMap

NewIntIntMap returns an empty IntIntMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewIntIntMapFrom Uses

func NewIntIntMapFrom(data map[int]int, safe ...bool) *IntIntMap

NewIntIntMapFrom creates and 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 Uses

func (m *IntIntMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*IntIntMap) Clone Uses

func (m *IntIntMap) Clone() *IntIntMap

Clone returns a new hash map with copy of current map data.

func (*IntIntMap) Contains Uses

func (m *IntIntMap) Contains(key int) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*IntIntMap) FilterEmpty Uses

func (m *IntIntMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*IntIntMap) Flip Uses

func (m *IntIntMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*IntIntMap) Get Uses

func (m *IntIntMap) Get(key int) int

Get returns the value by given <key>.

func (*IntIntMap) GetOrSet Uses

func (m *IntIntMap) GetOrSet(key int, value int) int

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*IntIntMap) GetOrSetFunc Uses

func (m *IntIntMap) GetOrSetFunc(key int, f func() int) int

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.

func (*IntIntMap) GetOrSetFuncLock Uses

func (m *IntIntMap) GetOrSetFuncLock(key int, f func() int) int

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*IntIntMap) IsEmpty Uses

func (m *IntIntMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*IntIntMap) Iterator Uses

func (m *IntIntMap) Iterator(f func(k int, v int) bool)

Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*IntIntMap) Keys Uses

func (m *IntIntMap) Keys() []int

Keys returns all keys of the map as a slice.

func (*IntIntMap) LockFunc Uses

func (m *IntIntMap) LockFunc(f func(m map[int]int))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*IntIntMap) Map Uses

func (m *IntIntMap) Map() map[int]int

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*IntIntMap) MapCopy Uses

func (m *IntIntMap) MapCopy() map[int]int

MapCopy returns a copy of the underlying data of the hash map.

func (*IntIntMap) MapStrAny Uses

func (m *IntIntMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*IntIntMap) MarshalJSON Uses

func (m *IntIntMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*IntIntMap) Merge Uses

func (m *IntIntMap) Merge(other *IntIntMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*IntIntMap) Pop Uses

func (m *IntIntMap) Pop() (key, value int)

Pop retrieves and deletes an item from the map.

func (*IntIntMap) Pops Uses

func (m *IntIntMap) Pops(size int) map[int]int

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*IntIntMap) RLockFunc Uses

func (m *IntIntMap) RLockFunc(f func(m map[int]int))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*IntIntMap) Remove Uses

func (m *IntIntMap) Remove(key int) int

Remove deletes value from map by given <key>, and return this deleted value.

func (*IntIntMap) Removes Uses

func (m *IntIntMap) Removes(keys []int)

Removes batch deletes values of the map by keys.

func (*IntIntMap) Replace Uses

func (m *IntIntMap) Replace(data map[int]int)

Replace the data of the map with given <data>.

func (*IntIntMap) Search Uses

func (m *IntIntMap) Search(key int) (value int, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*IntIntMap) Set Uses

func (m *IntIntMap) Set(key int, val int)

Set sets key-value to the hash map.

func (*IntIntMap) SetIfNotExist Uses

func (m *IntIntMap) SetIfNotExist(key int, value int) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*IntIntMap) SetIfNotExistFunc Uses

func (m *IntIntMap) SetIfNotExistFunc(key int, f func() int) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*IntIntMap) SetIfNotExistFuncLock Uses

func (m *IntIntMap) SetIfNotExistFuncLock(key int, f func() int) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*IntIntMap) Sets Uses

func (m *IntIntMap) Sets(data map[int]int)

Sets batch sets key-values to the hash map.

func (*IntIntMap) Size Uses

func (m *IntIntMap) Size() int

Size returns the size of the map.

func (*IntIntMap) UnmarshalJSON Uses

func (m *IntIntMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*IntIntMap) Values Uses

func (m *IntIntMap) Values() []int

Values returns all values of the map as a slice.

type IntStrMap Uses

type IntStrMap struct {
    // contains filtered or unexported fields
}

func NewIntStrMap Uses

func NewIntStrMap(safe ...bool) *IntStrMap

NewIntStrMap returns an empty IntStrMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewIntStrMapFrom Uses

func NewIntStrMapFrom(data map[int]string, safe ...bool) *IntStrMap

NewIntStrMapFrom creates and 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 Uses

func (m *IntStrMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*IntStrMap) Clone Uses

func (m *IntStrMap) Clone() *IntStrMap

Clone returns a new hash map with copy of current map data.

func (*IntStrMap) Contains Uses

func (m *IntStrMap) Contains(key int) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*IntStrMap) FilterEmpty Uses

func (m *IntStrMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*IntStrMap) Flip Uses

func (m *IntStrMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*IntStrMap) Get Uses

func (m *IntStrMap) Get(key int) string

Get returns the value by given <key>.

func (*IntStrMap) GetOrSet Uses

func (m *IntStrMap) GetOrSet(key int, value string) string

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*IntStrMap) GetOrSetFunc Uses

func (m *IntStrMap) GetOrSetFunc(key int, f func() string) string

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.

func (*IntStrMap) GetOrSetFuncLock Uses

func (m *IntStrMap) GetOrSetFuncLock(key int, f func() string) string

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*IntStrMap) IsEmpty Uses

func (m *IntStrMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*IntStrMap) Iterator Uses

func (m *IntStrMap) Iterator(f func(k int, v string) bool)

Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*IntStrMap) Keys Uses

func (m *IntStrMap) Keys() []int

Keys returns all keys of the map as a slice.

func (*IntStrMap) LockFunc Uses

func (m *IntStrMap) LockFunc(f func(m map[int]string))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*IntStrMap) Map Uses

func (m *IntStrMap) Map() map[int]string

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*IntStrMap) MapCopy Uses

func (m *IntStrMap) MapCopy() map[int]string

MapCopy returns a copy of the underlying data of the hash map.

func (*IntStrMap) MapStrAny Uses

func (m *IntStrMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*IntStrMap) MarshalJSON Uses

func (m *IntStrMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*IntStrMap) Merge Uses

func (m *IntStrMap) Merge(other *IntStrMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*IntStrMap) Pop Uses

func (m *IntStrMap) Pop() (key int, value string)

Pop retrieves and deletes an item from the map.

func (*IntStrMap) Pops Uses

func (m *IntStrMap) Pops(size int) map[int]string

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*IntStrMap) RLockFunc Uses

func (m *IntStrMap) RLockFunc(f func(m map[int]string))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*IntStrMap) Remove Uses

func (m *IntStrMap) Remove(key int) string

Remove deletes value from map by given <key>, and return this deleted value.

func (*IntStrMap) Removes Uses

func (m *IntStrMap) Removes(keys []int)

Removes batch deletes values of the map by keys.

func (*IntStrMap) Replace Uses

func (m *IntStrMap) Replace(data map[int]string)

Replace the data of the map with given <data>.

func (*IntStrMap) Search Uses

func (m *IntStrMap) Search(key int) (value string, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*IntStrMap) Set Uses

func (m *IntStrMap) Set(key int, val string)

Set sets key-value to the hash map.

func (*IntStrMap) SetIfNotExist Uses

func (m *IntStrMap) SetIfNotExist(key int, value string) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*IntStrMap) SetIfNotExistFunc Uses

func (m *IntStrMap) SetIfNotExistFunc(key int, f func() string) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*IntStrMap) SetIfNotExistFuncLock Uses

func (m *IntStrMap) SetIfNotExistFuncLock(key int, f func() string) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*IntStrMap) Sets Uses

func (m *IntStrMap) Sets(data map[int]string)

Sets batch sets key-values to the hash map.

func (*IntStrMap) Size Uses

func (m *IntStrMap) Size() int

Size returns the size of the map.

func (*IntStrMap) UnmarshalJSON Uses

func (m *IntStrMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*IntStrMap) Values Uses

func (m *IntStrMap) Values() []string

Values returns all values of the map as a slice.

type ListMap Uses

type ListMap struct {
    // contains filtered or unexported fields
}

func NewListMap Uses

func NewListMap(safe ...bool) *ListMap

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> is used to specify whether using map in concurrent-safety, which is false in default.

func NewListMapFrom Uses

func NewListMapFrom(data map[interface{}]interface{}, safe ...bool) *ListMap

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 Uses

func (m *ListMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*ListMap) Clone Uses

func (m *ListMap) Clone(safe ...bool) *ListMap

Clone returns a new link map with copy of current map data.

func (*ListMap) Contains Uses

func (m *ListMap) Contains(key interface{}) (ok bool)

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*ListMap) FilterEmpty Uses

func (m *ListMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*ListMap) Flip Uses

func (m *ListMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*ListMap) Get Uses

func (m *ListMap) Get(key interface{}) (value interface{})

Get returns the value by given <key>.

func (*ListMap) GetOrSet Uses

func (m *ListMap) GetOrSet(key interface{}, value interface{}) interface{}

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*ListMap) GetOrSetFunc Uses

func (m *ListMap) GetOrSetFunc(key interface{}, f func() interface{}) interface{}

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

func (*ListMap) GetOrSetFuncLock Uses

func (m *ListMap) GetOrSetFuncLock(key interface{}, f func() interface{}) interface{}

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the map.

func (*ListMap) GetVar Uses

func (m *ListMap) GetVar(key interface{}) *gvar.Var

GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.

func (*ListMap) GetVarOrSet Uses

func (m *ListMap) GetVarOrSet(key interface{}, value interface{}) *gvar.Var

GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.

func (*ListMap) GetVarOrSetFunc Uses

func (m *ListMap) GetVarOrSetFunc(key interface{}, f func() interface{}) *gvar.Var

GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.

func (*ListMap) GetVarOrSetFuncLock Uses

func (m *ListMap) GetVarOrSetFuncLock(key interface{}, f func() interface{}) *gvar.Var

GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.

func (*ListMap) IsEmpty Uses

func (m *ListMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*ListMap) Iterator Uses

func (m *ListMap) Iterator(f func(key, value interface{}) bool)

Iterator is alias of IteratorAsc.

func (*ListMap) IteratorAsc Uses

func (m *ListMap) IteratorAsc(f func(key interface{}, value interface{}) bool)

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 Uses

func (m *ListMap) IteratorDesc(f func(key interface{}, value interface{}) bool)

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 Uses

func (m *ListMap) Keys() []interface{}

Keys returns all keys of the map as a slice in ascending order.

func (*ListMap) Map Uses

func (m *ListMap) Map() map[interface{}]interface{}

Map returns a copy of the underlying data of the map.

func (*ListMap) MapStrAny Uses

func (m *ListMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*ListMap) MarshalJSON Uses

func (m *ListMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*ListMap) Merge Uses

func (m *ListMap) Merge(other *ListMap)

Merge merges two link maps. The <other> map will be merged into the map <m>.

func (*ListMap) Pop Uses

func (m *ListMap) Pop() (key, value interface{})

Pop retrieves and deletes an item from the map.

func (*ListMap) Pops Uses

func (m *ListMap) Pops(size int) map[interface{}]interface{}

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*ListMap) Remove Uses

func (m *ListMap) Remove(key interface{}) (value interface{})

Remove deletes value from map by given <key>, and return this deleted value.

func (*ListMap) Removes Uses

func (m *ListMap) Removes(keys []interface{})

Removes batch deletes values of the map by keys.

func (*ListMap) Replace Uses

func (m *ListMap) Replace(data map[interface{}]interface{})

Replace the data of the map with given <data>.

func (*ListMap) Search Uses

func (m *ListMap) Search(key interface{}) (value interface{}, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*ListMap) Set Uses

func (m *ListMap) Set(key interface{}, value interface{})

Set sets key-value to the map.

func (*ListMap) SetIfNotExist Uses

func (m *ListMap) SetIfNotExist(key interface{}, value interface{}) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*ListMap) SetIfNotExistFunc Uses

func (m *ListMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*ListMap) SetIfNotExistFuncLock Uses

func (m *ListMap) SetIfNotExistFuncLock(key interface{}, f func() interface{}) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the map.

func (*ListMap) Sets Uses

func (m *ListMap) Sets(data map[interface{}]interface{})

Sets batch sets key-values to the map.

func (*ListMap) Size Uses

func (m *ListMap) Size() (size int)

Size returns the size of the map.

func (*ListMap) UnmarshalJSON Uses

func (m *ListMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*ListMap) Values Uses

func (m *ListMap) Values() []interface{}

Values returns all values of the map as a slice.

type Map Uses

type Map = AnyAnyMap

Map based on hash table, alias of AnyAnyMap.

func New Uses

func New(safe ...bool) *Map

New creates and returns an empty hash map. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewFrom Uses

func NewFrom(data map[interface{}]interface{}, safe ...bool) *Map

NewFrom creates and 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 <safe> is used to specify whether using tree in concurrent-safety, which is false in default.

func NewHashMap Uses

func NewHashMap(safe ...bool) *Map

NewHashMap creates and returns an empty hash map. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewHashMapFrom Uses

func NewHashMapFrom(data map[interface{}]interface{}, safe ...bool) *Map

NewHashMapFrom creates and 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 <safe> is used to specify whether using tree in concurrent-safety, which is false in default.

type StrAnyMap Uses

type StrAnyMap struct {
    // contains filtered or unexported fields
}

func NewStrAnyMap Uses

func NewStrAnyMap(safe ...bool) *StrAnyMap

NewStrAnyMap returns an empty StrAnyMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewStrAnyMapFrom Uses

func NewStrAnyMapFrom(data map[string]interface{}, safe ...bool) *StrAnyMap

NewStrAnyMapFrom creates and 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 Uses

func (m *StrAnyMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*StrAnyMap) Clone Uses

func (m *StrAnyMap) Clone() *StrAnyMap

Clone returns a new hash map with copy of current map data.

func (*StrAnyMap) Contains Uses

func (m *StrAnyMap) Contains(key string) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*StrAnyMap) FilterEmpty Uses

func (m *StrAnyMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*StrAnyMap) Flip Uses

func (m *StrAnyMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*StrAnyMap) Get Uses

func (m *StrAnyMap) Get(key string) interface{}

Get returns the value by given <key>.

func (*StrAnyMap) GetOrSet Uses

func (m *StrAnyMap) GetOrSet(key string, value interface{}) interface{}

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*StrAnyMap) GetOrSetFunc Uses

func (m *StrAnyMap) GetOrSetFunc(key string, f func() interface{}) interface{}

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

func (*StrAnyMap) GetOrSetFuncLock Uses

func (m *StrAnyMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*StrAnyMap) GetVar Uses

func (m *StrAnyMap) GetVar(key string) *gvar.Var

GetVar returns a gvar.Var with the value by given <key>. The returned gvar.Var is un-concurrent safe.

func (*StrAnyMap) GetVarOrSet Uses

func (m *StrAnyMap) GetVarOrSet(key string, value interface{}) *gvar.Var

GetVarOrSet returns a gvar.Var with result from GetVarOrSet. The returned gvar.Var is un-concurrent safe.

func (*StrAnyMap) GetVarOrSetFunc Uses

func (m *StrAnyMap) GetVarOrSetFunc(key string, f func() interface{}) *gvar.Var

GetVarOrSetFunc returns a gvar.Var with result from GetOrSetFunc. The returned gvar.Var is un-concurrent safe.

func (*StrAnyMap) GetVarOrSetFuncLock Uses

func (m *StrAnyMap) GetVarOrSetFuncLock(key string, f func() interface{}) *gvar.Var

GetVarOrSetFuncLock returns a gvar.Var with result from GetOrSetFuncLock. The returned gvar.Var is un-concurrent safe.

func (*StrAnyMap) IsEmpty Uses

func (m *StrAnyMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*StrAnyMap) Iterator Uses

func (m *StrAnyMap) Iterator(f func(k string, v interface{}) bool)

Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*StrAnyMap) Keys Uses

func (m *StrAnyMap) Keys() []string

Keys returns all keys of the map as a slice.

func (*StrAnyMap) LockFunc Uses

func (m *StrAnyMap) LockFunc(f func(m map[string]interface{}))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*StrAnyMap) Map Uses

func (m *StrAnyMap) Map() map[string]interface{}

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*StrAnyMap) MapCopy Uses

func (m *StrAnyMap) MapCopy() map[string]interface{}

MapCopy returns a copy of the underlying data of the hash map.

func (*StrAnyMap) MapStrAny Uses

func (m *StrAnyMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*StrAnyMap) MarshalJSON Uses

func (m *StrAnyMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*StrAnyMap) Merge Uses

func (m *StrAnyMap) Merge(other *StrAnyMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*StrAnyMap) Pop Uses

func (m *StrAnyMap) Pop() (key string, value interface{})

Pop retrieves and deletes an item from the map.

func (*StrAnyMap) Pops Uses

func (m *StrAnyMap) Pops(size int) map[string]interface{}

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*StrAnyMap) RLockFunc Uses

func (m *StrAnyMap) RLockFunc(f func(m map[string]interface{}))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*StrAnyMap) Remove Uses

func (m *StrAnyMap) Remove(key string) interface{}

Remove deletes value from map by given <key>, and return this deleted value.

func (*StrAnyMap) Removes Uses

func (m *StrAnyMap) Removes(keys []string)

Removes batch deletes values of the map by keys.

func (*StrAnyMap) Replace Uses

func (m *StrAnyMap) Replace(data map[string]interface{})

Replace the data of the map with given <data>.

func (*StrAnyMap) Search Uses

func (m *StrAnyMap) Search(key string) (value interface{}, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*StrAnyMap) Set Uses

func (m *StrAnyMap) Set(key string, val interface{})

Set sets key-value to the hash map.

func (*StrAnyMap) SetIfNotExist Uses

func (m *StrAnyMap) SetIfNotExist(key string, value interface{}) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*StrAnyMap) SetIfNotExistFunc Uses

func (m *StrAnyMap) SetIfNotExistFunc(key string, f func() interface{}) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*StrAnyMap) SetIfNotExistFuncLock Uses

func (m *StrAnyMap) SetIfNotExistFuncLock(key string, f func() interface{}) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*StrAnyMap) Sets Uses

func (m *StrAnyMap) Sets(data map[string]interface{})

Sets batch sets key-values to the hash map.

func (*StrAnyMap) Size Uses

func (m *StrAnyMap) Size() int

Size returns the size of the map.

func (*StrAnyMap) UnmarshalJSON Uses

func (m *StrAnyMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*StrAnyMap) Values Uses

func (m *StrAnyMap) Values() []interface{}

Values returns all values of the map as a slice.

type StrIntMap Uses

type StrIntMap struct {
    // contains filtered or unexported fields
}

func NewStrIntMap Uses

func NewStrIntMap(safe ...bool) *StrIntMap

NewStrIntMap returns an empty StrIntMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewStrIntMapFrom Uses

func NewStrIntMapFrom(data map[string]int, safe ...bool) *StrIntMap

NewStrIntMapFrom creates and 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 Uses

func (m *StrIntMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*StrIntMap) Clone Uses

func (m *StrIntMap) Clone() *StrIntMap

Clone returns a new hash map with copy of current map data.

func (*StrIntMap) Contains Uses

func (m *StrIntMap) Contains(key string) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*StrIntMap) FilterEmpty Uses

func (m *StrIntMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*StrIntMap) Flip Uses

func (m *StrIntMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*StrIntMap) Get Uses

func (m *StrIntMap) Get(key string) int

Get returns the value by given <key>.

func (*StrIntMap) GetOrSet Uses

func (m *StrIntMap) GetOrSet(key string, value int) int

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*StrIntMap) GetOrSetFunc Uses

func (m *StrIntMap) GetOrSetFunc(key string, f func() int) int

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

func (*StrIntMap) GetOrSetFuncLock Uses

func (m *StrIntMap) GetOrSetFuncLock(key string, f func() int) int

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*StrIntMap) IsEmpty Uses

func (m *StrIntMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*StrIntMap) Iterator Uses

func (m *StrIntMap) Iterator(f func(k string, v int) bool)

Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*StrIntMap) Keys Uses

func (m *StrIntMap) Keys() []string

Keys returns all keys of the map as a slice.

func (*StrIntMap) LockFunc Uses

func (m *StrIntMap) LockFunc(f func(m map[string]int))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*StrIntMap) Map Uses

func (m *StrIntMap) Map() map[string]int

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*StrIntMap) MapCopy Uses

func (m *StrIntMap) MapCopy() map[string]int

MapCopy returns a copy of the underlying data of the hash map.

func (*StrIntMap) MapStrAny Uses

func (m *StrIntMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*StrIntMap) MarshalJSON Uses

func (m *StrIntMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*StrIntMap) Merge Uses

func (m *StrIntMap) Merge(other *StrIntMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*StrIntMap) Pop Uses

func (m *StrIntMap) Pop() (key string, value int)

Pop retrieves and deletes an item from the map.

func (*StrIntMap) Pops Uses

func (m *StrIntMap) Pops(size int) map[string]int

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*StrIntMap) RLockFunc Uses

func (m *StrIntMap) RLockFunc(f func(m map[string]int))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*StrIntMap) Remove Uses

func (m *StrIntMap) Remove(key string) int

Remove deletes value from map by given <key>, and return this deleted value.

func (*StrIntMap) Removes Uses

func (m *StrIntMap) Removes(keys []string)

Removes batch deletes values of the map by keys.

func (*StrIntMap) Replace Uses

func (m *StrIntMap) Replace(data map[string]int)

Replace the data of the map with given <data>.

func (*StrIntMap) Search Uses

func (m *StrIntMap) Search(key string) (value int, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*StrIntMap) Set Uses

func (m *StrIntMap) Set(key string, val int)

Set sets key-value to the hash map.

func (*StrIntMap) SetIfNotExist Uses

func (m *StrIntMap) SetIfNotExist(key string, value int) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*StrIntMap) SetIfNotExistFunc Uses

func (m *StrIntMap) SetIfNotExistFunc(key string, f func() int) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*StrIntMap) SetIfNotExistFuncLock Uses

func (m *StrIntMap) SetIfNotExistFuncLock(key string, f func() int) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*StrIntMap) Sets Uses

func (m *StrIntMap) Sets(data map[string]int)

Sets batch sets key-values to the hash map.

func (*StrIntMap) Size Uses

func (m *StrIntMap) Size() int

Size returns the size of the map.

func (*StrIntMap) UnmarshalJSON Uses

func (m *StrIntMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*StrIntMap) Values Uses

func (m *StrIntMap) Values() []int

Values returns all values of the map as a slice.

type StrStrMap Uses

type StrStrMap struct {
    // contains filtered or unexported fields
}

func NewStrStrMap Uses

func NewStrStrMap(safe ...bool) *StrStrMap

NewStrStrMap returns an empty StrStrMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.

func NewStrStrMapFrom Uses

func NewStrStrMapFrom(data map[string]string, safe ...bool) *StrStrMap

NewStrStrMapFrom creates and 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 Uses

func (m *StrStrMap) Clear()

Clear deletes all data of the map, it will remake a new underlying data map.

func (*StrStrMap) Clone Uses

func (m *StrStrMap) Clone() *StrStrMap

Clone returns a new hash map with copy of current map data.

func (*StrStrMap) Contains Uses

func (m *StrStrMap) Contains(key string) bool

Contains checks whether a key exists. It returns true if the <key> exists, or else false.

func (*StrStrMap) FilterEmpty Uses

func (m *StrStrMap) FilterEmpty()

FilterEmpty deletes all key-value pair of which the value is empty.

func (*StrStrMap) Flip Uses

func (m *StrStrMap) Flip()

Flip exchanges key-value of the map to value-key.

func (*StrStrMap) Get Uses

func (m *StrStrMap) Get(key string) string

Get returns the value by given <key>.

func (*StrStrMap) GetOrSet Uses

func (m *StrStrMap) GetOrSet(key string, value string) string

GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.

func (*StrStrMap) GetOrSetFunc Uses

func (m *StrStrMap) GetOrSetFunc(key string, f func() string) string

GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

func (*StrStrMap) GetOrSetFuncLock Uses

func (m *StrStrMap) GetOrSetFuncLock(key string, f func() string) string

GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.

GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*StrStrMap) IsEmpty Uses

func (m *StrStrMap) IsEmpty() bool

IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.

func (*StrStrMap) Iterator Uses

func (m *StrStrMap) Iterator(f func(k string, v string) bool)

Iterator iterates the hash map with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.

func (*StrStrMap) Keys Uses

func (m *StrStrMap) Keys() []string

Keys returns all keys of the map as a slice.

func (*StrStrMap) LockFunc Uses

func (m *StrStrMap) LockFunc(f func(m map[string]string))

LockFunc locks writing with given callback function <f> within RWMutex.Lock.

func (*StrStrMap) Map Uses

func (m *StrStrMap) Map() map[string]string

Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.

func (*StrStrMap) MapCopy Uses

func (m *StrStrMap) MapCopy() map[string]string

MapCopy returns a copy of the underlying data of the hash map.

func (*StrStrMap) MapStrAny Uses

func (m *StrStrMap) MapStrAny() map[string]interface{}

MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.

func (*StrStrMap) MarshalJSON Uses

func (m *StrStrMap) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*StrStrMap) Merge Uses

func (m *StrStrMap) Merge(other *StrStrMap)

Merge merges two hash maps. The <other> map will be merged into the map <m>.

func (*StrStrMap) Pop Uses

func (m *StrStrMap) Pop() (key, value string)

Pop retrieves and deletes an item from the map.

func (*StrStrMap) Pops Uses

func (m *StrStrMap) Pops(size int) map[string]string

Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.

func (*StrStrMap) RLockFunc Uses

func (m *StrStrMap) RLockFunc(f func(m map[string]string))

RLockFunc locks reading with given callback function <f> within RWMutex.RLock.

func (*StrStrMap) Remove Uses

func (m *StrStrMap) Remove(key string) string

Remove deletes value from map by given <key>, and return this deleted value.

func (*StrStrMap) Removes Uses

func (m *StrStrMap) Removes(keys []string)

Removes batch deletes values of the map by keys.

func (*StrStrMap) Replace Uses

func (m *StrStrMap) Replace(data map[string]string)

Replace the data of the map with given <data>.

func (*StrStrMap) Search Uses

func (m *StrStrMap) Search(key string) (value string, found bool)

Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.

func (*StrStrMap) Set Uses

func (m *StrStrMap) Set(key string, val string)

Set sets key-value to the hash map.

func (*StrStrMap) SetIfNotExist Uses

func (m *StrStrMap) SetIfNotExist(key string, value string) bool

SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*StrStrMap) SetIfNotExistFunc Uses

func (m *StrStrMap) SetIfNotExistFunc(key string, f func() string) bool

SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

func (*StrStrMap) SetIfNotExistFuncLock Uses

func (m *StrStrMap) SetIfNotExistFuncLock(key string, f func() string) bool

SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.

SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.

func (*StrStrMap) Sets Uses

func (m *StrStrMap) Sets(data map[string]string)

Sets batch sets key-values to the hash map.

func (*StrStrMap) Size Uses

func (m *StrStrMap) Size() int

Size returns the size of the map.

func (*StrStrMap) UnmarshalJSON Uses

func (m *StrStrMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*StrStrMap) Values Uses

func (m *StrStrMap) Values() []string

Values returns all values of the map as a slice.

type TreeMap Uses

type TreeMap = gtree.RedBlackTree

Map based on red-black tree, alias of RedBlackTree.

func NewTreeMap Uses

func NewTreeMap(comparator func(v1, v2 interface{}) int, safe ...bool) *TreeMap

NewTreeMap instantiates a tree map with the custom comparator. The parameter <safe> is used to specify whether using tree in concurrent-safety, which is false in default.

func NewTreeMapFrom Uses

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 <safe> is used to specify whether using tree in concurrent-safety, which is false in default.

Package gmap imports 7 packages (graph) and is imported by 23 packages. Updated 2019-12-02. Refresh now. Tools for package owners.