dmap

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyAnyMap

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

AnyAnyMap 并发安全的hash字典表

func NewAnyAnyMap

func NewAnyAnyMap(safe ...bool) *AnyAnyMap

NewAnyAnyMap 创建hash表

func NewAnyAnyMapFrom

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

NewAnyAnyMapFrom 通过map创建hash表

func (*AnyAnyMap) Clear

func (that *AnyAnyMap) Clear()

Clear 清除map

func (*AnyAnyMap) Clone

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

Clone clone一份数据。并返回新的对象指针

func (*AnyAnyMap) Contains

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

Contains 判断传入的key是否存在于map中

func (*AnyAnyMap) FilterEmpty

func (that *AnyAnyMap) FilterEmpty()

FilterEmpty 清除空值

func (*AnyAnyMap) FilterNil

func (that *AnyAnyMap) FilterNil()

FilterNil 清除nil值

func (*AnyAnyMap) Flip

func (that *AnyAnyMap) Flip()

Flip 翻转key和value

func (*AnyAnyMap) Get

func (that *AnyAnyMap) Get(key interface{}) (value interface{})

Get 查找key

func (*AnyAnyMap) GetOrSet

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

GetOrSet 查找key对应的值是否存在,如果未找到,则写入

func (*AnyAnyMap) GetOrSetFunc

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

GetOrSetFunc 获取指定key的值,如果不存在,则通过方法f生成该值,并写入到map,然后返回 生成新值的方法未使用到锁,不会造成阻塞

func (*AnyAnyMap) GetOrSetFuncLock

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

GetOrSetFuncLock 与上面GetOrSetFunc方法的区别,在乎生成值的时候是否使用锁,此方法生成值的时候会使用到做,传入的方法不能阻塞, 不然会造成map加锁不可读写

func (*AnyAnyMap) IsEmpty

func (that *AnyAnyMap) IsEmpty() bool

IsEmpty 判断map是否为空

func (*AnyAnyMap) Iterator

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

Iterator 迭代hash表

func (*AnyAnyMap) Keys

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

Keys 返回map的所有key

func (*AnyAnyMap) LockFunc

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

LockFunc 加锁执行方法操作数据

func (*AnyAnyMap) Map

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

Map 返回原始结构

func (*AnyAnyMap) MapCopy

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

MapCopy copy一份map数据

func (*AnyAnyMap) MarshalJSON

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

MarshalJSON json序列化

func (*AnyAnyMap) Merge

func (that *AnyAnyMap) Merge(other *AnyAnyMap)

Merge 合并两个map

func (*AnyAnyMap) Pop

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

Pop 随机获取一个字典key,value

func (*AnyAnyMap) Pops

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

Pops 随机获取指定size的字典值,-1表示获取全部

func (*AnyAnyMap) RLockFunc

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

RLockFunc 加读锁执行方法操作数据

func (*AnyAnyMap) Random

func (that *AnyAnyMap) Random() (key, value interface{}, exist bool)

func (*AnyAnyMap) Remove

func (that *AnyAnyMap) Remove(key interface{}) (value interface{})

Remove 移除指定的key,并返回它对应的值

func (*AnyAnyMap) Removes

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

Removes 批量删除key

func (*AnyAnyMap) Replace

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

Replace 替换map

func (*AnyAnyMap) Search

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

Search 通过key查找value

func (*AnyAnyMap) Set

func (that *AnyAnyMap) Set(key interface{}, value interface{})

Set 设置key value

func (*AnyAnyMap) SetIfNotExist

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

SetIfNotExist 如果map中不存在该key,则设置

func (*AnyAnyMap) SetIfNotExistFunc

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

SetIfNotExistFunc 如果map中不存在key,则调用方法f生成,生成的时候未加锁

func (*AnyAnyMap) SetIfNotExistFuncLock

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

SetIfNotExistFuncLock 如果map中不存在key,则调用方法f生成,生成的时候加锁

func (*AnyAnyMap) Sets

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

Sets 批量设置

func (*AnyAnyMap) Size

func (that *AnyAnyMap) Size() int

Size 返回map的长度

func (*AnyAnyMap) String

func (that *AnyAnyMap) String() string

转换成字符串

func (*AnyAnyMap) UnmarshalJSON

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

UnmarshalJSON json反序列化

func (*AnyAnyMap) UnmarshalValue

func (that *AnyAnyMap) UnmarshalValue(value interface{}) (err error)

func (*AnyAnyMap) Values

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

Values 返回map所有的值

type HashMap

type HashMap = AnyAnyMap // HashMap is alias of AnyAnyMap.

type Map

type Map = AnyAnyMap // Map is alias of AnyAnyMap.

func New

func New(safe ...bool) *Map

New 创建一个map对象

func NewFrom

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

NewFrom 创建一个map对象,并把参数data作为值

func NewHashMap

func NewHashMap(safe ...bool) *Map

NewHashMap 创建一个map对象

func NewHashMapFrom

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

NewHashMapFrom 创建一个map对象,并把参数data作为值

type StrAnyMap added in v0.0.3

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

func NewStrAnyMap added in v0.0.3

func NewStrAnyMap(safe ...bool) *StrAnyMap

NewStrAnyMap 返回一个空的StrAnyMap对象

func NewStrAnyMapFrom added in v0.0.3

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

NewStrAnyMapFrom 从给定的map 创建并返回一个哈希映射。 注意,param map将被设置为底层数据map(没有深层复制), 当改变外部映射时,可能会有一些并发安全问题。

func (*StrAnyMap) Clear added in v0.0.3

func (that *StrAnyMap) Clear()

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

func (*StrAnyMap) Clone added in v0.0.3

func (that *StrAnyMap) Clone() *StrAnyMap

Clone 返回一个新的StrAnyMap对象,其中的值是赋值的当前StrAnyMap对象

func (*StrAnyMap) Contains added in v0.0.3

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

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

func (*StrAnyMap) FilterEmpty added in v0.0.3

func (that *StrAnyMap) FilterEmpty()

FilterEmpty 删除map对象中的空值 空值的定义: 0, nil, false, "", len(slice/map/chan) == 0

func (*StrAnyMap) FilterNil added in v0.0.3

func (that *StrAnyMap) FilterNil()

FilterNil 删除map中值为 nil的对象

func (*StrAnyMap) Flip added in v0.0.3

func (that *StrAnyMap) Flip()

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

func (*StrAnyMap) Get added in v0.0.3

func (that *StrAnyMap) Get(key string) (value interface{})

Get 返回key对应的值

func (*StrAnyMap) GetOrSet added in v0.0.3

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

GetOrSet 如果存在,则返回,不存在则设置并返回

func (*StrAnyMap) GetOrSetFunc added in v0.0.3

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

GetOrSetFunc 如果存在,则返回,不存在则设置并返回

func (*StrAnyMap) GetOrSetFuncLock added in v0.0.3

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

GetOrSetFuncLock 如果存在,则返回,不存在则设置并返回

func (*StrAnyMap) GetVar added in v0.0.3

func (that *StrAnyMap) GetVar(key string) *dvar.Var

GetVar 返回Var类型的值

func (*StrAnyMap) GetVarOrSet added in v0.0.3

func (that *StrAnyMap) GetVarOrSet(key string, value interface{}) *dvar.Var

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

func (*StrAnyMap) GetVarOrSetFunc added in v0.0.3

func (that *StrAnyMap) GetVarOrSetFunc(key string, f func() interface{}) *dvar.Var

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

func (*StrAnyMap) GetVarOrSetFuncLock added in v0.0.3

func (that *StrAnyMap) GetVarOrSetFuncLock(key string, f func() interface{}) *dvar.Var

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

func (*StrAnyMap) IsEmpty added in v0.0.3

func (that *StrAnyMap) IsEmpty() bool

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

func (*StrAnyMap) Iterator added in v0.0.3

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

Iterator 迭代该map,如果其中有一次迭代返回false,则整个迭代过程将会终止

func (*StrAnyMap) Keys added in v0.0.3

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

Keys returns all keys of the map as a slice.

func (*StrAnyMap) LockFunc added in v0.0.3

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

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

func (*StrAnyMap) Map added in v0.0.3

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

Map 返回一个原始的map对象

func (*StrAnyMap) MapCopy added in v0.0.3

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

MapCopy 把对象的值赋值到新的地址中并返回

func (*StrAnyMap) MapStrAny added in v0.0.3

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

MapStrAny 返回一个map[string]interface{}类型的map对象

func (*StrAnyMap) MarshalJSON added in v0.0.3

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*StrAnyMap) Merge added in v0.0.3

func (that *StrAnyMap) Merge(other *StrAnyMap)

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

func (*StrAnyMap) Pop added in v0.0.3

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

Pop 从map中返回一个元素并删除它

func (*StrAnyMap) Pops added in v0.0.3

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

Pops 返回指定数量的元素并删除它

func (*StrAnyMap) RLockFunc added in v0.0.3

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

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

func (*StrAnyMap) Remove added in v0.0.3

func (that *StrAnyMap) Remove(key string) (value interface{})

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

func (*StrAnyMap) Removes added in v0.0.3

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

Removes batch deletes values of the map by keys.

func (*StrAnyMap) Replace added in v0.0.3

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

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

func (*StrAnyMap) Search added in v0.0.3

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

Search 查找key是否存在map中,知道则返回该值,found为true,没有找到value=nil,found=false

func (*StrAnyMap) Set added in v0.0.3

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

Set 写入key,val到map中

func (*StrAnyMap) SetIfNotExist added in v0.0.3

func (that *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 added in v0.0.3

func (that *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 added in v0.0.3

func (that *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 added in v0.0.3

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

Sets 批量写入

func (*StrAnyMap) Size added in v0.0.3

func (that *StrAnyMap) Size() int

Size returns the size of the map.

func (*StrAnyMap) String added in v0.0.3

func (that *StrAnyMap) String() string

String returns the map as a string.

func (*StrAnyMap) UnmarshalJSON added in v0.0.3

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

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*StrAnyMap) UnmarshalValue added in v0.0.3

func (that *StrAnyMap) UnmarshalValue(value interface{}) (err error)

UnmarshalValue is an interface implement which sets any type of value for map.

func (*StrAnyMap) Values added in v0.0.3

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

Values returns all values of the map as a slice.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL